NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/39814: A stopping process will be waked up by any signals.
>Number: 39814
>Category: kern
>Synopsis: A stopping process will be waked up by any signals.
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 27 15:15:00 +0000 2008
>Originator: Yasushi Oshima
>Release: NetBSD-current
>Organization:
>Environment:
NetBSD sweety 4.99.73 NetBSD 4.99.73 (GENERIC) #237: Tue Oct 21 07:52:35 JST
2008 oshima@sweety:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
I think a stopping process by SIGSTOP will be waked up by only SIGCONT signal.
However it seems that any signals wake up the process in current.
This is different from NetBSD 4.0 and other OSs.
>How-To-Repeat:
In the following program in NetBSD-current, the signal handler of the
child-process that outputs the message 'Caught signal 30' to /tmp/xxx and exits
will be called, and the parent-process will output the message 'kill: No such
process'.
In NetBSD-4.0, the parent-process outputs 'PID xxx still exists' and the
child-process
exists under stopping state. This child-process will catch the SIGUSR1 signal
by 'kill -CONT PID'.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
FILE *fp;
void handler(int sig)
{
fprintf(fp,"Caught signal %d\n",sig);
fclose(fp);
exit(0);
}
main()
{
pid_t pid;
pid = fork();
if ( pid == -1 ) {
err(1,"fork");
} else if ( pid != 0 ) {
/* Main Process */
printf ("PID:%d\n",pid);
sleep(1);
kill(pid, SIGSTOP); /* send SIGSTOP to child */
sleep(1);
kill(pid, SIGUSR1); /* send SIGUSR1 to child --- this signal
will be pending */
sleep(1);
if (kill(pid,0)==0) {
printf("PID %d still exists.\n", pid);
} else {
err(1,"kill");
}
exit(0);
} else {
/* Child Process */
struct sigaction sa;
memset(&sa,0,sizeof(sa));
sa.sa_handler = handler;
fp = fopen("/tmp/xxx","w");
if (fp == NULL ) {
perror("fopen");
exit(1);
}
exit(0);
} else {
/* Child Process */
struct sigaction sa;
memset(&sa,0,sizeof(sa));
fp = fopen("/tmp/xxx","w");
if (fp == NULL ) {
perror("fopen");
exit(1);
}
close(0);
close(1);
close(2);
setsid();
sa.sa_handler = handler;
sigaction(SIGUSR1, &sa, 0);
while(1); /* loop */
}
}
>Fix:
unknown
Home |
Main Index |
Thread Index |
Old Index