Re: core dumps on signals

H. Peter Anvin (hpa@transmeta.com)
Fri, 26 Feb 1999 02:19:20 -0800 (PST)


>
> H. Peter Anvin writes:
> > By author: "Albert D. Cahalan" <acahalan@cs.uml.edu>
>
> >> So the library is supposed to define signal names (and forget libc 5)...
> >> Which signal is supposed to be SIGSYS? Neither of the two junk signals
> >> dump core, so they can not be substituted without kernel changes.
> >>
> >> (only 4 of 8 ports have this problem: i386, arm, m68k, ppc)
> >>
> >> Name Unix98 Linux
> >> ---------------------
> >> ABRT core core
> >> FPE core core
> >> ILL core core
> >> QUIT core core
> >> SEGV core core
> >> TRAP core core
> >> SYS core n/a (Missing! This is bad!)
> >> BUS core exit
> >> XCPU core exit
> >> XFSZ core exit
> >> ALRM exit exit
> >> HUP exit exit
> >> INT exit exit
> >> KILL exit exit
> >> PIPE exit exit
> >> POLL exit exit
> >> PROF exit exit
> >> TERM exit exit
> >> USR1 exit exit
> >> USR2 exit exit
> >> VTALRM exit exit
> >> PWR n/a exit (normal systems would ignore by default)
> >
> > I don't think so; SIGPWR sent to init means it should shut down the
> > system as soon as possible. If init dies, the system gets uncleanly
> > shut down, but less uncleanly than a power interruption (at least the
> > disks are idled.) Therefore this is eminently sensible.
>
> If init dies, init is broken. It should catch the signal.
>
> Signals are often used for odd purposes. For example, SIGHUP is often
> used to make a daemon reread config files. Compatibility with the rest
> of the world would be nice.
>
> >> STKFLT n/a exit (this is Linux-specific junk)
> >> UNUSED n/a exit (this is Linux-specific junk)
> >
> > I would still like to suggest these two getting recycled as SIGTHREAD1
> > and SIGTHREAD2, for LinuxThreads to use.
>
> No, we need them for SIGSYS and SIGEMT. The Linux-specific signals only
> exist on i386, arm, ppc, and m68k. Every other port (sparc*, alpha, mips)
> defines SIGSYS and SIGEMT like a normal UNIX or BSD would. We can't have
> a LinuxThreads that only works on 1/2 of the Linux ports. LinuxThreads
> should be using a reserved portion of the RT signals.
>
> For example, Digital Unix has SIGRTMIN==33 and SIGRTMAX==48.
>
> As another example, UnixWare 7 defines these:
> SIGWAITING 32 Ignore All LWPs blocked
> SIGLWP 33 Ignore Virtual Interprocessor Interrupt for thread library
> SIGAIO 34 Ignore Asynchronous I/O
>
> The same with AIX: they define almost a dozen high numbered signals.
>
> >> WINCH n/a ignore
> >> CHLD ignore ignore
> >> URG ignore ignore
> >> TSTP stop ignore if daemon, otherwise exit
> >> TTIN stop ignore if daemon, otherwise exit
> >> TTOU stop ignore if daemon, otherwise exit
> >
> > This is just wrong: Linux stops if the handler is default on TSTP,
> > TTIN, and TTOU which is perfectly correct behaviour. If what you had
> > up there was true, ^Z would kill your process.
>
> I know it looks strange, but I tested it. Signals were set to
> SIG_DFL before the test. By "daemon" I mean the process forked,
> had the parent exit, and had the child call setsid().
>

Try again:

#define SIGTSTP 20

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

int main(int argc, char *argv[])
{
int signum = atoi(argv[1]);
struct sigaction sa;

sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_restorer = 0;

sigaction(signum, &sa, NULL);

printf("Ready, pid = %ld!\n", (long)getpid());

while(1);

printf("We shouldn't get here...\n");
exit(1);
}

: cesium 13 ; gcc -o sigcheck sigcheck.c
: cesium 14 ; ./sigcheck 20
Ready, pid = 28164!

[[ In another xterm ]]
kill -20 28164

[[ On the original xterm ]]
Suspended

If what you claimed was true, almost nothing would work. The odds are
overwhelming that your test is just plain bogus.

-hpa

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/