[cs631apue] question about signal

hao wu hwu9 at stevens.edu
Mon Oct 28 15:47:04 EDT 2013


Dear All,

When testing  pending.c.

Hit ^\ , then Hit ^C immediately, will got:

=> Establishing initial signal hander via signal(3).
^\sig_quit: caught SIGQUIT (1), now sleeping
^Csig_int: caught SIGINT (2), returning immediately
sig_quit: exiting (2)

=> Time for a second interruption.

My question is why hit  ^C, the sig_quit will exit immediately, rather than
sleep 3 seconds?


Thanks.



below is the code  for sig_quit and sig_int

static void
sig_quit(int signo) {
    fprintf(stderr, "sig_quit: caught SIGQUIT (%d), now sleeping\n", ++s);
    sleep(SLEEP);   //this was skiped when hit ^C ,why??
    fprintf(stderr, "sig_quit: exiting (%d)\n", s);
}

static void
sig_int(int signo) {
    fprintf(stderr, "sig_int: caught SIGINT (%d), returning immediately\n",
++s);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20131028/9e4ba62c/attachment.html>


More information about the cs631apue mailing list