From: Steven Rostedt <rostedt@goodmis.org>
To: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
Cc: Robert Wilkens <robw@optonline.net>, linux-kernel@vger.kernel.org
Subject: Re: Signal handling possibly wrong
Date: Tue, 09 Aug 2005 16:03:32 -0400 [thread overview]
Message-ID: <1123617812.18332.199.camel@localhost.localdomain> (raw)
In-Reply-To: <42F906EB.6060106@fujitsu-siemens.com>
[-- Attachment #1: Type: text/plain, Size: 699 bytes --]
On Tue, 2005-08-09 at 21:41 +0200, Bodo Stroesser wrote:
> S
> > To me, the man pages make more sense, and I think the kernel is wrong.
>
> Yes, that's what I think, too. If someone doesn't want additional signals
> to be masked, he can set sa_mask to be empty.
> OTOH, I have no idea, what POSIX specifies. Maybe kernel is right and man
> page is wrong?
>
> Bodo
> >
Man pages and kernel are right. I just tested this out on 2.6.13-rc3
with the attached program and it seems to follow what is stated in the
man pages. So the assumption of what the code did by looking at it
proves to be the mistake. :-)
Conclusion: sa_mask defers the signals. SA_NODEFER defers the sent
signal.
-- Steve
[-- Attachment #2: signal.c --]
[-- Type: text/x-csrc, Size: 2423 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
void user1(int x)
{
int pid = getpid();
printf("pid[%d]: user1 start\n",pid);
sleep(5);
printf("pid[%d]: user1 stopped\n",pid);
}
void user2(int x)
{
int pid = getpid();
printf("pid[%d]:in user2\n",pid);
}
void intr(int x)
{
int pid = getpid();
printf("pid[%d]: received SIGINT\n",pid);
exit(0);
}
void start1(void)
{
struct sigaction act;
memset(&act,0,sizeof(act));
act.sa_handler = intr;
if ((sigaction(SIGINT,&act,NULL)) < 0) {
perror("child1: sigaction");
exit(-1);
}
act.sa_handler = user1;
sigaddset(&act.sa_mask,SIGUSR2);
if ((sigaction(SIGUSR1,&act,NULL)) < 0) {
perror("child1: sigaction");
exit(-1);
}
act.sa_handler = user2;
if ((sigaction(SIGUSR2,&act,NULL)) < 0) {
perror("child1: sigaction");
exit(-1);
}
for (;;)
;
}
void start2(void)
{
struct sigaction act;
memset(&act,0,sizeof(act));
act.sa_handler = intr;
if ((sigaction(SIGINT,&act,NULL)) < 0) {
perror("child2: sigaction");
exit(-1);
}
act.sa_handler = user1;
act.sa_flags |= SA_NODEFER;
if ((sigaction(SIGUSR1,&act,NULL)) < 0) {
perror("child2: sigaction");
exit(-1);
}
act.sa_handler = user2;
if ((sigaction(SIGUSR2,&act,NULL)) < 0) {
perror("child1: sigaction");
exit(-1);
}
for (;;)
;
}
int main(int argc, char **argv)
{
int pid[2];
if ((pid[0] = fork()) < 0) {
perror("fork");
} else if (!pid[0]) {
start1();
exit(0);
}
if ((pid[1] = fork()) < 0) {
perror("fork");
} else if (!pid[1]) {
start2();
exit(0);
}
printf("parent sending %d SIGUSR1\n",pid[0]);
kill(pid[0],SIGUSR1);
sleep(1);
printf("parent sending %d SIGUSR2\n",pid[0]);
kill(pid[0],SIGUSR2);
sleep(5);
printf("parent sending %d SIGUSR1\n",pid[0]);
kill(pid[0],SIGUSR1);
sleep(1);
printf("parent sending %d SIGUSR1\n",pid[0]);
kill(pid[0],SIGUSR1);
sleep(1);
printf("parent sending %d SIGINT\n",pid[0]);
kill(pid[0],SIGINT);
printf("parent sending %d SIGUSR1\n",pid[1]);
kill(pid[1],SIGUSR1);
sleep(1);
printf("parent sending %d SIGUSR2\n",pid[1]);
kill(pid[1],SIGUSR2);
sleep(5);
printf("parent sending %d SIGUSR1\n",pid[1]);
kill(pid[1],SIGUSR1);
sleep(1);
printf("parent sending %d SIGUSR1\n",pid[1]);
kill(pid[1],SIGUSR1);
sleep(1);
printf("parent sending %d SIGINT\n",pid[1]);
kill(pid[1],SIGINT);
exit(0);
}
next prev parent reply other threads:[~2005-08-09 20:03 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-09 17:44 Signal handling possibly wrong Bodo Stroesser
2005-08-09 18:26 ` Robert Wilkens
2005-08-09 18:32 ` Bodo Stroesser
2005-08-09 18:39 ` Robert Wilkens
2005-08-09 18:44 ` Bodo Stroesser
2005-08-09 19:04 ` Robert Wilkens
2005-08-09 19:33 ` Steven Rostedt
2005-08-09 19:41 ` Bodo Stroesser
2005-08-09 20:03 ` Steven Rostedt [this message]
2005-08-09 20:19 ` Steven Rostedt
2005-08-09 20:49 ` Chris Wright
2005-08-09 21:00 ` [PATCH] Fix i386 signal handling of NODEFER, should not affect sa_mask (was: Re: Signal handling possibly wrong) Steven Rostedt
2005-08-09 21:06 ` Chris Wright
2005-08-09 21:07 ` [PATCH] Fix PPC signal handling of NODEFER, should not affect sa_mask Steven Rostedt
2005-08-09 21:27 ` Linus Torvalds
2005-08-10 3:10 ` Steven Rostedt
2005-08-10 3:33 ` Steven Rostedt
2005-08-12 18:37 ` Jan Engelhardt
2005-08-12 18:45 ` Chris Wright
2005-08-12 18:59 ` Steven Rostedt
2005-08-12 19:27 ` Steven Rostedt
2005-08-12 19:31 ` Jesper Juhl
2005-08-12 21:08 ` Steven Rostedt
2005-08-14 11:24 ` Jesper Juhl
2005-08-12 21:53 ` Steven Rostedt
2005-08-14 22:04 ` Kyle Moffett
2005-08-13 18:47 ` Marc Ballarin
2005-08-10 9:44 ` Bodo Stroesser
2005-08-09 21:04 ` Signal handling possibly wrong Chris Wright
2005-08-10 9:11 ` Bodo Stroesser
2005-08-10 16:20 ` Chris Wright
2005-08-09 19:33 ` Jeremy Maitin-Shepard
2005-08-09 18:50 ` smbus driver for ati xpress 200m yhlu
2005-08-09 22:57 ` Andi Kleen
2005-08-10 2:51 ` yhlu
2005-08-10 7:27 ` Andi Kleen
[not found] <11855.1123690475@www37.gmx.net>
2005-08-10 16:22 ` Signal handling possibly wrong Michael Kerrisk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1123617812.18332.199.camel@localhost.localdomain \
--to=rostedt@goodmis.org \
--cc=bstroesser@fujitsu-siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robw@optonline.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox