Possible 4.2 bug (process doing select() terminated by SIGTSTP)
Per Hedeland
per at erix.UUCP
Mon Feb 20 19:01:26 AEST 1984
<>
I posted this a couple of weeks ago, but I suspect it got lost somewhere,
since I got absolutely *no* response (*someone* must know!(?)):
Enclosed is a dummy program demonstrating the use of select() for catching
interrupts when expecting input. It works fine for this purpose, but strange
things happen if you try to suspend it: If you hit ^Z, the process just isn't
there anymore when you do a subsequent 'fg'. The (c)shell manages to exclaim
[n] Stopped seltest
but that's all.
Closer examination reveals that the exit status says 'terminated by signal 18',
which is obviously true, but *why* is it terminated? Further clues:
The process doesn't actually terminate until the shell receives it's next
input, and if you send it a SIGCONT (from another terminal) before that, it
doesn't terminate at all.
If you select() for input from another terminal (than control) everything's
fine, but if you select() for input from control terminal and send SIGTSTP
from another, it still terminates.
I'm afraid I'm no expert on the interiors of the kernel, and although I've
vainly scanned through the code for select() (including the tty driver),
psig() etc leaves me far behind. Any info appreciated. (Please do *not* tell
me how to avoid the problem though, I'm interested in it's *cause*.)
Per Hedeland
{decvax, philabs}!mcvax!enea!per
seltest.c --------------------------------------------------------------------
#include <sys/time.h>
#include <signal.h>
#include <stdio.h>
interrupt(sig)
int sig;
{
return;
}
main()
{
int readfds;
char line[80];
signal(SIGINT, interrupt);
while (1) {
printf("question ? ");
fflush(stdout);
readfds = 1 << fileno(stdin);
if (select(20, &readfds, (int *)0, (int *)0, (struct timeval *)0) > 0) {
gets(line);
printf("answer: %s\n", line);
} else {
printf("\nyou hit interrupt!\n");
}
}
}
------------------------------------------------------------------------------
More information about the Comp.unix.wizards
mailing list