Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!seismo!mcvax!ukc!stc!root44!miduet!misoft!adam From: adam@misoft.UUCP Newsgroups: comp.bugs.4bsd Subject: Bug in /bin/sh - interrupt problem. Message-ID: <644@gec-mi-at.co.uk> Date: Fri, 14-Aug-87 10:38:18 EDT Article-I.D.: gec-mi-a.644 Posted: Fri Aug 14 10:38:18 1987 Date-Received: Sun, 16-Aug-87 18:40:09 EDT Sender: news@gec-mi-at.co.uk Reply-To: adam@gec-mi-at.co.uk (Adam Quantrill) Distribution: world Organization: Marconi Instruments Ltd., St. Albans, UK Lines: 65 Keywords: bug bourne shell interrupt Bug: bourne shell returns with a funny status when a child is interrupted. Repeat-by: compile and run the following programs: --------------------------put in waiter.c----cc waiter.c -o waiter--------- main(argc, argv, environ) int argc; char *argv[], *environ[]; { printf("%d\n", system("waittest")); } --------------------------------------------------------------------------- ------------------------put in waittest.c----cc waittest.c -o waittest---- #include piss_about() { signal(SIGINT, SIG_IGN); puts("Hello"); signal(SIGINT, piss_about); } main(argc, argv, environ) int argc; char *argv[], *environ[]; { /* Interrupt handler.*/ signal(SIGINT, piss_about); /* I interrupt myself to make the point.*/ kill(getpid(), SIGINT); /* Give the user a chance to interrupt me.*/ getchar(); /* Exit cleanly!!!!!*/ exit(0); } -------------------------------------------------------------------------- To run: a) Normal exit - type waiter b) Funny exit - type waiter Wait for the "Hello" Type ^C (or whatever your interrupt char is) Type - note the funny exit status. These programs work o.k. on system 5. I can only conjecture that the shell exec'ed by the call to 'system' is getting muddled when a keyboard interrupt occurs. This is especially irritating when one interrupts a program in order to turn on tracing, for example. If the program is part of a 'make' facility, it appears that the program has failed. -Adam. /* If at first it don't compile, kludge, kludge again.*/ {NUKE THE GAY WHALE!}