Strange behaviour of select() call when ^Z typed, (4.2BSD)
Brett Galloway
brett at wjvax.UUCP
Sat Sep 28 05:35:21 AEST 1985
The following program illustrates what may be a bug in the select() call
(and the underlying kernel code):
----------- Start of file -----------------
#include <stdio.h>
main(argc,argv)
{
char buf[32];
int readfds;
int i;
while(1) {
printf("Type something: ");
fflush(stdout);
readfds=1;
if(select(1,&readfds,0,0,0) > 0) {
gets(buf);
printf("'%s' typed.\n",buf);
if(buf[0] == '~')
break;
}
}
}
------------ End of file -------------
When this is executed, and ^Z is typed at the prompt (i.e. while the
program is sitting in the select()), the program does stop, but then
its status changes. The csh detects a stopped state, but the program's
process in fact exits. This bug is (seemingly) intermittent. I have
other programs which sit on select()'s for input which may or may not
die when a SIGTSTP signal is sent to them.
Sending SIGTSTP instead of typing ^Z may also cause the process to die.
Sending SIGTSTP to a process on a pipe, however, never caused it to
die, so I assume that this problem involves some interaction with the
(new) tty driver.
Does anyone out there know what is happening? If so, I would appreciate
hearing about it.
More information about the Comp.unix.wizards
mailing list