Missing in sigaction
Missing in sigaction
- Subject: Missing in sigaction
- From: Nat! <email@hidden>
- Date: Tue, 27 Mar 2012 20:57:04 +0200
Hi
instead of many words, here's the output of two program runs once with a sleep( 2) - as in seconds, not as in man - commented in and out. What I believe this demonstrates, is that on Darwin (Kernel Version 10.8.0), blocked signal information is lost, which is incovenient. gdb has a similiar problem.
Or it shows that I am misunderstanding something ;)
The problem is not that the signal is occurring less often, that's expected, but that the struct __siginfo has trouble remembering things.
Ciao
Nat!
Run #1 (without sleep(2) in signal_action)
993: sigaction
993: fork
993: fork
993: wait
994: kill
994: sleep
993: signal 30 from { 30, 0, 0, 994 }
995: kill
995: sleep
993: signal 30 from { 30, 0, 0, 995 }
994: kill
994: sleep
993: signal 30 from { 30, 0, 0, 994 }
995: kill
995: sleep
993: signal 30 from { 30, 0, 0, 995 }
994: _exit
995: _exit
993: wait
993: _exit
Run #2 (with sleep( 2) in signal_action)
973: sigaction
973: fork
973: fork
973: wait
974: kill
974: sleep
973: signal 30 from { 30, 0, 0, 974 }
973: sleep
975: kill
975: sleep
974: kill
974: sleep
975: kill
975: sleep
973: signal 30 from { 30, 0, 0, 0 } <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
974: _exit
973: sleep
975: _exit
973: wait
973: _exit
Source code.
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void p_log( char *s)
{
printf( "%d: %s\n", getpid(), s);
}
static void signal_action( int signal, struct __siginfo *info, void *data)
{
printf( "%d: signal %d from { %d, %d, %d, %d }\n", getpid(), signal, info->si_signo, info->si_errno, info->si_code, info->si_pid);
/// COMMENT-UNCOMMENT ///
p_log( "sleep");
sleep( 2);
}
static void _test( void)
{
p_log( "fork");
if( ! fork())
{
p_log( "kill");
kill( getppid(), SIGUSR1);
p_log( "sleep");
sleep( 1);
p_log( "kill");
kill( getppid(), SIGUSR1);
p_log( "sleep");
sleep( 1);
p_log( "_exit");
_exit( 0);
}
}
int main( int argc, const char * argv[])
{
struct sigaction act;
int status;
sigemptyset( &act.sa_mask);
act.__sigaction_u.__sa_sigaction = signal_action;
act.sa_flags = SA_SIGINFO|SA_RESTART;
p_log( "sigaction");
sigaction( SIGUSR1, &act, NULL);
_test();
_test();
p_log( "wait");
while( wait( &status) == -1);
p_log( "wait");
while( wait( &status) == -1);
p_log( "_exit");
_exit( 0);
}
------------------------------------------------------
As an ex-Atari employee, who has known both
high income and protracted unemployment,
I can assure you that nobody should enter programming
for the money. -- Chris Crawford
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden