lkml.org 
[lkml]   [1996]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectMore SIGCHLD musings
Date
From
Hello again.

First of all, apologies to Mr. SIGCHLD. He's been getting the
wrong end of the stick lately. Let's hope things get better for
him soon.

Now, here's the phenomenon.

When I run the included program on SunOS 4.1.3. and Solaris 2.5,
it prints "sig" as expected. But when I run it on Linux 2.0.0,
or indeed Linux 1.2.13, nothing happens.

What's going on here?
Is the SIGCHLD signal somehow discarded when waitpid is called?
What does POSIX have to say about this?

--------------------------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

void sighandler()
{
write(STDERR_FILENO, "sig\n", 4);
return;
}

int main(void)
{
sigset_t set, oset;
struct sigaction act;
pid_t pid;

sigemptyset(&set);
sigaddset(&set, SIGCHLD);
sigprocmask(SIG_BLOCK, &set, &oset);
act.sa_handler = sighandler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGCHLD, &act, 0);

switch (pid = fork()) {
case -1:
perror("fork");
return 1;
case 0:
_exit(0);
break;
default:
while (waitpid(pid, 0, 0) == -1) {
if (errno != EINTR)
break;
}
}

sigprocmask(SIG_SETMASK, &oset, 0);
return 0;
}
--
Michiel Boland <boland@sci.kun.nl>
University of Nijmegen
The Netherlands


\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.041 / U:3.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site