Bug 72650

Summary: Signal Handling always seems to restart system calls
Product: [Developer tools] valgrind Reporter: Crispin Flowerday <gnome>
Component: generalAssignee: Jeremy Fitzhardinge <jeremy>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 2.1 CVS   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:

Description Crispin Flowerday 2004-01-14 17:41:30 UTC
Using the test case below, normally and under versions of valgrind in debian
before 2.1.0, you can exit the program using Ctrl+C, using valginr 2.1.0, it is
impossible to quit using Ctrl+C.

#include <unistd.h>
#include <signal.h>

static void nullfunction( int ) {}

static void 
setup_signal( int sig, void(*routine)(int) )
{
   struct sigaction act;
   act.sa_flags   = 0;
   act.sa_handler = (void(*)(int))routine;
   sigemptyset( &act.sa_mask );
   sigaction( sig, &act, 0 );
}

int main()
{
   char buff[8];
   setup_signal( SIGINT, nullfunction );
   read( 0, buff, sizeof( buff ) );
   return 0;
}
Comment 1 Tom Hughes 2004-01-14 17:46:32 UTC
Another point to note is that this is the correct behaviour if SA_RESTART is specified when the handler is installed, so when fixing this we need to make sure that the system call is restarted in that case...
Comment 2 Jeremy Fitzhardinge 2004-01-16 03:16:32 UTC
Fixed in CVS.