| K-mart Cashier 2007-05-26, 7:23 pm |
| Lately I've started to look at the source to to some larger *nix
programs. Anyhow, I'm finding out that I'm struggling to understand
the parts that I can make sense out of -(.
Okay, with there, below is the function and comment
in wrt_sig.c
RETSIGTYPE intr(int sig)
{
if (insys && (sig == SIGINT))
{
signal (SIGINT, (RETSIGTYPE (*)())intr);
longjmp(sysenv,1);
}
done(1);
}
/* SUSP -- Suspend the process. Unlike shell escapes, we restore the
wrttmp
* entry before stopping. This is because, unlike shell escapes, we
can't
* assume that stopped processes will be restarted in the reverse
order in
* which they were stopped.
*/
#ifdef JOB_CONTROL
RETSIGTYPE susp()
{
int was_cbreak= in_cbreak;
int mask;
/* Disable further signals */
mask= sigblock(sigmask(SIGTSTP));
/* Restore modes and make wrttmp look like we exited */
if (in_cbreak) cbreak(FALSE);
if (postpone) show_lastmesg();
reset_modes();
signal(SIGTSTP,SIG_DFL);
sigsetmask(0);
kill(getpid(),SIGTSTP);
/* STOP HERE */
sigsetmask(mask);
signal(SIGTSTP,(RETSIGTYPE (*)())susp);
/* Reinstate cbreak mode and wrttmp entry */
if (was_cbreak) cbreak(TRUE);
update_modes();
if (!telegram) set_modes();
}
#endif /*JOB_CONTROL*/
I don't get what the author means by
"This is because, unlike shell escapes, we can't
* assume that stopped processes will be restarted in the reverse
order in
* which they were stopped."
|