NetBSD Problem Report #39814
From www@NetBSD.org Mon Oct 27 15:10:55 2008
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id A7F7D63BC30
for <gnats-bugs@gnats.netbsd.org>; Mon, 27 Oct 2008 15:10:55 +0000 (UTC)
Message-Id: <20081027151055.688B763B88A@narn.NetBSD.org>
Date: Mon, 27 Oct 2008 15:10:55 +0000 (UTC)
From: oshima-ya@yagoto-urayama.jp
Reply-To: oshima-ya@yagoto-urayama.jp
To: gnats-bugs@NetBSD.org
Subject: A stopping process will be waked up by any signals.
X-Send-Pr-Version: www-1.0
>Number: 39814
>Category: kern
>Synopsis: A stopping process will be waked up by any signals.
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: rmind
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 27 15:15:00 +0000 2008
>Closed-Date: Sun Mar 29 05:06:38 +0000 2009
>Last-Modified: Tue Mar 31 23:45:00 +0000 2009
>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
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: kern-bug-people->rmind
Responsible-Changed-By: rmind@NetBSD.org
Responsible-Changed-When: Sat, 21 Mar 2009 20:06:58 +0000
Responsible-Changed-Why:
Take.
State-Changed-From-To: open->closed
State-Changed-By: rmind@NetBSD.org
State-Changed-When: Sun, 29 Mar 2009 05:06:38 +0000
State-Changed-Why:
Fixed, will be pulled up to 5.0 branch. Thanks for good report (with
the test-case!) and sorry for delay.
From: Mindaugas Rasiukevicius <rmind@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39814 CVS commit: src/sys/kern
Date: Sun, 29 Mar 2009 05:02:47 +0000
Module Name: src
Committed By: rmind
Date: Sun Mar 29 05:02:47 UTC 2009
Modified Files:
src/sys/kern: kern_sig.c
Log Message:
kpsignal2: do not start process (when it is stopped) for all termination
signals (i.e. SA_KILL), just if SIGKILL (or SIGCONT). Improve comments.
Make some functions static, remove unused sigrealloc() prototype.
Fixes PR/39814. Similar patch reviewed by <ad>.
To generate a diff of this commit:
cvs rdiff -u -r1.296 -r1.297 src/sys/kern/kern_sig.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/39814 CVS commit: [netbsd-5] src/sys/kern
Date: Tue, 31 Mar 2009 23:41:23 +0000
Module Name: src
Committed By: snj
Date: Tue Mar 31 23:41:23 UTC 2009
Modified Files:
src/sys/kern [netbsd-5]: kern_sig.c
Log Message:
Pull up following revision(s) (requested by rmind in ticket #620):
sys/kern/kern_sig.c: revision 1.297
kpsignal2: do not start process (when it is stopped) for all termination
signals (i.e. SA_KILL), just if SIGKILL (or SIGCONT). Improve comments.
Make some functions static, remove unused sigrealloc() prototype.
Fixes PR/39814. Similar patch reviewed by <ad>.
To generate a diff of this commit:
cvs rdiff -u -r1.289.4.3 -r1.289.4.4 src/sys/kern/kern_sig.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.