linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Frank Jas <frank@jrware.com>
To: linuxppc-dev@lists.linuxppc.org
Subject: Signal mask restore anomaly
Date: Wed, 16 Aug 2000 12:25:36 -0700	[thread overview]
Message-ID: <200008161925.MAA00373@tallis.jrware.com> (raw)


Under certain circumstances, a signal blocked while a
signal handler is executing will not be restored.


This is my kernel info:

Linux 2.2.6-15apmac #1 Mon May 31 03:54:09 EDT 1999 ppc unknown

The behavior does not occur under Intel versions (2.2.5-15smp).


Below is a program that tests out the use of signal masks
with sigaction().  It sets up a handler for SIGINT and
SIGTSTP.  The handler for SIGTSTP adds SIGINT to
the signal mask for that handler.  So while the SIGTSTP
handler is executing, occurences of SIGINT will be
blocked until the handler returns.  SIGTSTP will also
be blocked.


#define _POSIX_SOURCE 1
#define _GNU_SOURCE 1

#include <signal.h>
#include <errno.h>
#include <stdio.h>

void on_intr (signum)
	int signum ;
{
	printf("\n    Interrupted with signal %d. \n", signum) ;
}

void on_tstp (signum)
	int signum;
{
	printf ("\n     Handler for SIGTSTP wants text or ^C or ^Z: ") ;
	getchar () ;
}

void main ()
{
	struct sigaction  new_intr_action;
	struct sigaction  new_tstp_action;
	int    c ;

	sigemptyset (&new_intr_action.sa_mask);
	new_intr_action.sa_handler = on_intr;
	new_intr_action.sa_flags   = SA_RESTART;

	sigaction  (SIGINT, &new_intr_action, 0);

	sigemptyset (&new_tstp_action.sa_mask);
	sigaddset   (&new_tstp_action.sa_mask, SIGINT);
	new_tstp_action.sa_handler = on_tstp;
	new_tstp_action.sa_flags   = SA_RESTART;

	sigaction  (SIGTSTP, &new_tstp_action, 0);

	printf("Starting main input loop enter text or ^Z or ^C:\n") ;

	while ((c = getchar ()) != EOF) {
		putchar (c);
	}
}


The following execution sequence leads to the anomalous behavior.


Trigger the SIGTSTP handler with a ^Z
While executing the handler, deliver a ^Z and ^C
Hit return to return from the handler.
Another instance of the SIGTSTP handler should execute.
Hit return to return from that instance of the handler.
Notice that the SIGINT handler does not execute and should have.
Any subsequent SIGINT are apparently blocked.

Apparently the nested occurence of SIGTSTP effected the restore
of the SIGINT mask, and the handling of the pending SIGINT.

The same behavior will result using 'kill' from another window
to send the signals.

Please let me know if this is not the appropriate venue for this
post.

Frank Jas

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

             reply	other threads:[~2000-08-16 19:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-16 19:25 Frank Jas [this message]
2000-08-17  3:11 ` Signal mask restore anomaly David A. Gatwood
2000-08-17  4:05 ` Jeffrey Hawkins
2000-08-17 12:43   ` Hendricks, Kevin
2000-08-17 13:05     ` Hendricks, Kevin

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=200008161925.MAA00373@tallis.jrware.com \
    --to=frank@jrware.com \
    --cc=linuxppc-dev@lists.linuxppc.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;
as well as URLs for NNTP newsgroup(s).