Unix Programming - I don't understand this code comment

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > May 2007 > I don't understand this code comment





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author I don't understand this code comment
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."

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com