D
Dave Vandervies
[interactivity].... if you have a reliable way of generating SIGINT
(ctrl-C should do this on both Unix and Windows), you can fake
but then:
background?), re-ignoring\n",stderr);oldsigfunc=signal(SIGTERM,sigint_handler); [and]
fputs("SIGTERM was ignored (perhaps we're running in thesignal(SIGTERM,SIG_IGN);
Presumably these are all supposed to read SIGINT as well.
Yep. I blame it on having too much blood in my caffeine stream when
I wrote that. (You wouldn't want to run your "interactive attention"
handler when the system is requesting that your program terminate.)
Not quite on topic for the group, but perhaps significant, there
is a pitfall in using an interrupt key on Unix-like systems (whether
it applies to MS-Windows is less clear -- I try to avoid Windows
as much as possible and in any case Windows systems are not commonly
used with remote displays half a world away over long-response-time
TCP connections...). In particular, interrupting a program may
flush queued but as-yet-undisplayed output, at the OS level. There
is nothing a portable C program can do about this.
Would this cause problems for a program that only sets a flag in the
signal handler and does the actual input handling (suspending normal
execution of the program while doing so) elsewhere when that flag is set?
dave