wmk@baskin.UUCP (04/07/87)
I've "discovered," much to my dismay, that the Bourne shell does not let me pass the modified signal mask to the sub-processes it spawns; it only passes the original one. (We have a Gould 6040 running UTX/32 1.2, a BSD 4.2 system with a little Sys V.) The situation is: I run a C program that sets the signal mask to ignore interrupt and quit signals. It then calls a /bin/sh script. Within that script I reset the mask (i.e., trap 2 3) and then call another C program. The mask being passed to that program still ignores SIGINT and SIGQUIT. My problem is that _I want to do this_! Is there a way to do this from within the shell script? We could call a second C program which would reset the mask and _then_ call our programs, but this seems inelegant. Are there any better ways? Thanks in advance, -- Bill Kules "We're on the road ...seismo!vrdxhq!baskin!wmk and we're gunning for the Buddha" ...decuac!baskin!wmk -- Shriekback
m5d@bobkat.UUCP (04/09/87)
In article <319@baskin.UUCP> wmk@baskin.UUCP (Bill Kules) writes: >I've "discovered," much to my dismay, that the Bourne shell does >not let me pass the modified signal mask to the sub-processes it >spawns; it only passes the original one. (We have a Gould 6040 >running UTX/32 1.2, a BSD 4.2 system with a little Sys V.) > >The situation is: I run a C program that sets the signal mask >to ignore interrupt and quit signals. It then calls a /bin/sh >script. Within that script I reset the mask (i.e., trap 2 3) >and then call another C program. The mask being passed to that >program still ignores SIGINT and SIGQUIT. > >Thanks in advance, >-- >Bill Kules "We're on the road >...seismo!vrdxhq!baskin!wmk and we're gunning for the Buddha" >...decuac!baskin!wmk -- Shriekback There is a difference between the signal mask and the mechanism by which signals are ignored. The call signal(SIGBLAH, SIG_IGN); does nothing at all to the signal mask. The mask is set with sigblock() or sigsetmask() (or sort of with sigvec()). Notice also that the man page for sh says that "trap" with a missing command resets the signals to their original value -- that is, the value the shell found upon entry. This value is of course SIG_IGN, since the parent C program set that. Why not try removing the "trap" statement from the script? -- Mike McNally, mercifully employed at Digital Lynx --- Where Plano Road the Mighty Flood of Forest Lane doth meet, And Garland fair, whose perfumed air flows soft about my feet... uucp: {texsun,killer,infotel}!pollux!bobkat!m5d (214) 238-7474
jfh@killer.UUCP (04/09/87)
I ran into this once. In K&R or the old Green Unix book someone gives the code to system(3). Scarf this code and modify it to handle the signals the way you want. Or, chew on this ... --------------- cut here at your own risk ---------------- #include <signal.h> system (s) char *s; { int child; int status; int i; int (*ifunc) ()); int (*qfunc) ()); child = fork (); if (child < 0) return (-1); if (child > 0) { ifunc = signal (SIG_INT, SIG_IGN); qfunc = signal (SIG_QUIT, SIG_IGN); while (wait (&status) != child) ; signal (SIG_INT, ifunc); signal (SIG_QUIT, qfunc); return (status); } else { signal (SIG_INT, SIG_DFL); signal (SIG_QUIT, SIG_DFL); execle ("/bin/sh", "-c", s, (char *) 0); exit (0377); } } -------------------------- slash ----------------------- Okay? - John. Disclaimer: You are responsible for your own actions. Including believing that this code works ...