Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!oddjob!gargoyle!ihnp4!iwtpm!pgn From: pgn@iwtpm.ATT.COM (XMPF50-Novorolsky) Newsgroups: comp.unix.wizards Subject: Ksh signal anomoly Message-ID: <105@iwtpm.ATT.COM> Date: Tue, 17-Nov-87 13:45:33 EST Article-I.D.: iwtpm.105 Posted: Tue Nov 17 13:45:33 1987 Date-Received: Sat, 21-Nov-87 12:30:49 EST Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 64 Keywords: SIGINT Bug or feature? Has anyone using K-shell ever seen this anomoly, and have an explanation. (i.e. Is it a bug or a feature ) When catching a signal and exiting from the program from within the signal handling function, the exit value from a caught SIGINT is the intended exit value plus 128. When other signal (SIGQUIT, SIGTERM or SIGHUP) are caught, ksh reports the correct return value (2 in the following example. A search through the manuals resulted in some suspicion and confusion surrounding the exit values returned by child processes. (ksh may be retaining some of the information returned by the child process, in this case, sig) So, is ksh providing a feature that I don't understand, or does it have a bug? (If it is a feature, it seems to be a little inconsistent) For an example, try the following: sig.c ------------------------------------------------------- #include #define INC 2 void sig_clean(); void exit(); main() { (void) signal(SIGHUP, sig_clean); (void) signal(SIGINT, sig_clean); (void) signal(SIGQUIT, sig_clean); (void) signal(SIGTERM, sig_clean); (void) pause(); } void sig_clean(sig) int sig; { (void)signal(sig,SIG_IGN); (void)printf("Signal %d caught\n",sig); (void)signal(sig,sig_clean); exit(INC); } ------------------------------------------------------- From ksh: $ sig # Kill the sig process with the signal of your choice $ echo $? Any systems that I have tried this on show an exit value of 130. If the call to sig and echo $? are placed in an executeable shell file, the return value reported is 2. Paul Novorolsky