[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20070219151337.d2594811.kamezawa.hiroyu@jp.fujitsu.com>
Date: Mon, 19 Feb 2007 15:13:37 +0900
From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>
To: LKML <linux-kernel@...r.kernel.org>
Subject: [Qeustion][Maybe BUG?] simaltaneous wait and SIGCHLD handling
Hi,
>From SUSv3, I expected SIGCHLD from dead processes (already reaped by wait(2))
should be cleared. But it seems that such situation is not handled in Linux.
Here is a test program. set sigchld handler and call waitpid() in main().
==
#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
int sigchld_handler(int sig,siginfo_t *info, void *uc)
{
fprintf(stderr,"Letter from the hell...(%d)\n",info->si_pid);
}
int main(int argc, char *argv)
{
struct sigaction act;
sigset_t block;
int status;
pid_t pid;
sigemptyset(&block);
sigaddset(&block, SIGCHLD);
act.sa_sigaction = sigchld_handler;
act.sa_mask = block;
act.sa_flags = SA_SIGINFO|SA_RESTART;
sigaction(SIGCHLD,&act,NULL);
pid = fork();
if (!pid) {
sleep(3);
exit(0);
}
sigprocmask(SIG_BLOCK, &block, NULL);
pid = waitpid(pid, &status, 0);
fprintf(stderr,"wait end -> %d\n",pid);
sigprocmask(SIG_UNBLOCK, &block, NULL);
exit(0);
}
==
Result is here
==
[kamezawa@...ares ~]$ ./waittest
wait end -> 5841
Letter from the hell...(5841)
==
Is this an expected result ? I think SIGCHLD shouldn't be delivered.
-Kame
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists