[comp.bugs.4bsd] Bug in /bin/sh - interrupt problem.

adam@misoft.UUCP (08/14/87)

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 <signal.h>


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 <return> <return>

b) Funny exit - type waiter <return>

Wait for the "Hello"

Type ^C (or whatever your interrupt char is)

Type <return> - 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!}