sigemptyset(&mask); sigaddset(&mask, SIGTSTP); sigprocmask(SIG_UNBLOCK, &mask, NULL); signal(SIGTSTP, SIG_DFL); /* reset disposition to default */ kill(getpid(), SIGTSTP); /* and send the signal to ourself */ /* * we won't return from the kill until we're continued */ signal(SIGTSTP, sig_tstp); /* reestablish signal handler */
Why not just send ourself SIGSTOP:
ReplyDeletekill(getpid(), SIGSTOP);
Instead of all this:
sigemptyset(&mask);
sigaddset(&mask, SIGTSTP);
sigprocmask(SIG_UNBLOCK, &mask, NULL);
signal(SIGTSTP, SIG_DFL); /* reset disposition to default */
kill(getpid(), SIGTSTP); /* and send the signal to ourself */
/*
* we won't return from the kill until we're continued
*/
signal(SIGTSTP, sig_tstp); /* reestablish signal handler */