62Signal(
int signo, SigFunc* newhandler,
bool doInterrupt )
69 struct sigaction
action, old;
71 memset( &old, 0,
sizeof(old) );
75 memmove( &
action.sa_handler, &newhandler,
sizeof(SigFunc*) );
76 sigemptyset( &
action.sa_mask );
78 if ( signo == SIGCHLD ) {
79 action.sa_flags |= SA_NOCLDSTOP;
86 if ( signo == SIGALRM || doInterrupt ) {
88 action.sa_flags |= SA_INTERRUPT;
96 return ( sigaction( signo, &
action, &old ) < 0 ) ?
98 (SigFunc*) old.sa_handler;
112 while ( (
pid = waitpid( -1, &status, WNOHANG )) > 0 ) {
113 if ( WIFEXITED(status) ) {
114 fprintf( stderr,
"child (pid=%ld) reaped, status %d\n%c",
115 (
long)
pid, WEXITSTATUS(status), 0 );
116 }
else if ( WIFSIGNALED(status) ) {
117 fprintf( stderr,
"child (pid=%ld) died on signal %d%s\n%c",
118 (
long)
pid, WTERMSIG(status),
120 WCOREDUMP(status) ?
" (core generated)" :
"",
126 fprintf( stderr,
"detected dead child (pid=%ld), status %d\n%c",
127 (
long)
pid, status, 0 );
static bool action(int fd, size_t metasize, const char *fn, const char *url, const SquidMetaList &meta)
SigFunc * Signal(int signo, SigFunc *newhandler, bool doInterrupt)