t45126@iemisi.dhc (John Durko) (10/06/89)
Can someone help me with a problem. I am trying to trap signal 18 (SIGTSTP) so that i can reset some terminal stuff before program is suspend by ^Z. The question is how to i actually suspend the program. I have tried saving the value returned from signal() and then calling it from my handler routine but the program core dumps with a segmentation fault. If anyone could give me some pointers i would appreciate it. By the way i'm using SunOS 4.0.3. -- ___ ___ ___ ___ _ _ ___ /__/ / / /__ / /\ / / _ Stephen Martin, Boeing Canada, Toronto. /__/ /__/ /__ _/_ / / /__/ Nuke the Raisins UUCP: smartin@iemisi.UUCP {uunet|suncan}!jtsv16!isdserv!iemisi!t45126
gwyn@smoke.BRL.MIL (Doug Gwyn) (10/07/89)
In article <T45126.89Oct6084404@iemisi.dhc> t45126@iemisi.dhc (John Durko) writes:
-Can someone help me with a problem. I am trying to trap signal 18 (SIGTSTP)
-so that i can reset some terminal stuff before program is suspend by ^Z. The
-question is how to i actually suspend the program. I have tried saving the
-value returned from signal() and then calling it from my handler routine but
-the program core dumps with a segmentation fault.
Your signal handler should block the signal, act on it, reset the action
to the original return from the signal() call that planted your handler,
then send another occurrence of the signal to the process via kill().
faulkner@megan.Apollo.COM (Donald Vaughn Faulkner) (10/09/89)
In article <T45126.89Oct6084404@iemisi.dhc> t45126@iemisi.dhc (John Durko) writes: > Can someone help me with a problem. I am trying to trap signal 18 (SIGTSTP) > so that i can reset some terminal stuff before program is suspend by ^Z. The > question is how to i actually suspend the program. I have tried saving the > value returned from signal() and then calling it from my handler routine but > the program core dumps with a segmentation fault. If anyone could give me > some pointers i would appreciate it. By the way i'm using SunOS 4.0.3. the value returned by signal is probably "0" --- default handler, y'know... You can use "kill (getpid (), SIGSTOP)" to suspend yourself. -- Don Faulkner Customer Service OS Products Apollo Computer faulkner@apollo.hp.com
gil@taux01.UUCP (Gil Shwed) (10/10/89)
In article <T45126.89Oct6084404@iemisi.dhc> t45126@iemisi.dhc (John Durko) writes: >Can someone help me with a problem. I am trying to trap signal 18 (SIGTSTP) >so that i can reset some terminal stuff before program is suspend by ^Z. The following code should be used on 4.3BSD (SunOS included) [ 4.2BSD derived systems should replace sigmask(i) with 1<<(i-1) ]: in your main program: signal(SIGTSTP, tstp); Handler code: tstp() { /* Restore tty values, or whatever you like. */ /* First, Use the default action - STOP process */ signal(SIGTSTP, SIG_DFL); /* * Turn off blocking of SIGTSTP from blocked signals. Otherwise * It will be masked until we get out of the handler. */ sigsetmask(sigblock(0) & ~sigmask(SIGTSTP)); /* * Stop myself */ kill(getpid(), SIGTSTP); /* * Set handler again for next use. */ signal(SIGTSTP, tstp); /* Restore/Set tty values back to programs' */ } Hope that helps. -- Gil