From: Steven Rostedt <rostedt@goodmis.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: Robert Wilkens <robw@optonline.net>,
linux-kernel@vger.kernel.org,
Bodo Stroesser <bstroesser@fujitsu-siemens.com>,
Andrew Morton <akpm@osdl.org>,
gdt@linuxppc.org, Chris Wright <chrisw@osdl.org>
Subject: Re: [PATCH] Fix PPC signal handling of NODEFER, should not affect sa_mask
Date: Tue, 09 Aug 2005 23:33:35 -0400 [thread overview]
Message-ID: <1123644815.9553.37.camel@localhost.localdomain> (raw)
In-Reply-To: <1123643401.9553.32.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 790 bytes --]
On Tue, 2005-08-09 at 23:10 -0400, Steven Rostedt wrote:
> memset(&act,0,sizeof(act));
> sigaddset(&act.sa_mask,SIGUSR1);
> ret = testsig(&act,SIGUSR1,SIGUSR1);
> if (ret == 1) {
> printf("sa_mask does not block sig\n");
> } else if (ret == 0) {
> printf("sa_mask blocks sig\n");
> } else {
> printf("Unknown return code!!\n");
> }
>
> exit(0);
> exit(0);
Yuck! OK I was into the cut and paste here. This probably would look
much better as
ret = testsig(&act,SIGUSR1,SIGUSR1);
switch (ret) {
case 0:
printf("...");
break;
case 1:
printf("...");
break;
default:
printf("Unknown...");
}
And what was I doing with the double exits??
OK, time for bed.
-- Steve
[-- Attachment #2: test_signal.c --]
[-- Type: text/x-csrc, Size: 3696 bytes --]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
static int u1;
static int u2;
static void user1(int x)
{
/* for testing against itself */
if (u1)
u2 = 1;
u1 = 1;
sleep(5);
u1 = 0;
}
static void user2(int x)
{
if (u1)
u2 = 1;
}
static void intr(int x)
{
exit(u2);
}
static void start(struct sigaction *act)
{
struct sigaction a;
memset(&a,0,sizeof(a));
a.sa_handler = intr;
if ((sigaction(SIGINT,&a,NULL)) < 0) {
perror("sigaction");
exit(-1);
}
/*
* This is the testing handler
*/
act->sa_handler = user1;
if ((sigaction(SIGUSR1,act,NULL)) < 0) {
perror("sigaction");
exit(-1);
}
a.sa_handler = user2;
if ((sigaction(SIGUSR2,&a,NULL)) < 0) {
perror("sigaction");
exit(-1);
}
for (;;)
;
}
int testsig(struct sigaction *act, int sig1, int sig2)
{
int pid;
int status;
if ((pid = fork()) < 0) {
perror("fork");
} else if (!pid) {
/*
* Test1 sa_mask includes SIGUSR2
*/
start(act);
exit(0);
}
/*
* Send first signal to start the test.
*/
kill(pid,sig1);
/*
* SIGUSR1 sleeps for 5, just sleep for on here
* to make sure the system got it.
*/
sleep(1);
/*
* Send the second signal to the child, to see if
* this wakes it up.
*/
kill(pid,sig2);
sleep(1);
/*
* End the test.
*/
kill(pid,SIGINT);
waitpid(pid,&status,0);
return WEXITSTATUS(status);
}
int main(int argc, char **argv)
{
struct sigaction act;
int ret;
memset(&act,0,sizeof(act));
sigaddset(&act.sa_mask,SIGUSR2);
ret = testsig(&act,SIGUSR1,SIGUSR2);
switch (ret) {
case 0:
printf("sa_mask blocks other signals\n");
break;
case 1:
printf("sa_mask does not block other signals\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
act.sa_flags |= SA_NODEFER;
ret = testsig(&act,SIGUSR1,SIGUSR2);
switch (ret) {
case 0:
printf("SA_NODEFER blocks other signals\n");
break;
case 1:
printf("SA_NODEFER does not block other signals\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
act.sa_flags |= SA_NODEFER;
sigaddset(&act.sa_mask,SIGUSR2);
ret = testsig(&act,SIGUSR1,SIGUSR2);
switch (ret) {
case 0:
printf("SA_NODEFER does not affect sa_mask\n");
break;
case 1:
printf("SA_NODEFER affects sa_mask\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
act.sa_flags |= SA_NODEFER;
sigaddset(&act.sa_mask,SIGUSR1);
ret = testsig(&act,SIGUSR1,SIGUSR1);
switch (ret) {
case 0:
printf("SA_NODEFER and sa_mask blocks sig\n");
break;
case 1:
printf("SA_NODEFER and sa_mask does not block sig\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
ret = testsig(&act,SIGUSR1,SIGUSR1);
switch (ret) {
case 0:
printf("!SA_NODEFER blocks sig\n");
break;
case 1:
printf("!SA_NODEFER does not block sig\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
memset(&act,0,sizeof(act));
act.sa_flags |= SA_NODEFER;
ret = testsig(&act,SIGUSR1,SIGUSR1);
switch (ret) {
case 0:
printf("SA_NODEFER blocks sig\n");
break;
case 1:
printf("SA_NODEFER does not block sig\n");
break;
default:
printf("Unknown return code!!\n");
}
memset(&act,0,sizeof(act));
sigaddset(&act.sa_mask,SIGUSR1);
ret = testsig(&act,SIGUSR1,SIGUSR1);
switch (ret) {
case 0:
printf("sa_mask blocks sig\n");
break;
case 1:
printf("sa_mask does not block sig\n");
break;
default:
printf("Unknown return code!!\n");
}
exit(0);
}
next prev parent reply other threads:[~2005-08-10 3:33 UTC|newest]
Thread overview: 36+ 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
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 [this message]
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
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=1123644815.9553.37.camel@localhost.localdomain \
--to=rostedt@goodmis.org \
--cc=akpm@osdl.org \
--cc=bstroesser@fujitsu-siemens.com \
--cc=chrisw@osdl.org \
--cc=gdt@linuxppc.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robw@optonline.net \
--cc=torvalds@osdl.org \
/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
Powered by JetHome