[comp.unix.internals] how to suspend a process

coleman@cam.nist.gov (Sean Sheridan Coleman X5672) (02/06/91)

In a program I am writing, I want to be able to catch SIGTSTP
but if I do that, the process will not get suspended. How can
I do what the shell would do under normal situation, suspend the
process? Is sigsuspend the way to go? 

How to I get my program to restart or do I need to concern
myself with this problem?



Thanks

Sean Coleman
coleman@bldrdoc.gov

rbj@uunet.UU.NET (Root Boy Jim) (02/06/91)

In article <7016@alpha.cam.nist.gov> coleman@cam.nist.gov (Sean Sheridan Coleman X5672) writes:
>In a program I am writing, I want to be able to catch SIGTSTP
>but if I do that, the process will not get suspended. How can
>I do what the shell would do under normal situation, suspend the
>process? Is sigsuspend the way to go? 

In your handler, you send yourself a SIGSTOP, which you cannot catch.
You could also unregister your handler, then send a SIGTSTP.

>How to I get my program to restart ...

Another process sends it a SIGCONT, most likely your shell as the
result of typing "fg" or "bg".

> ...or do I need to concern myself with this problem?

Well, yess and no. The tricky thing is figuring out what to do
before and after you're suspended. Typical things are:
save and restore tty modes, flush output files, repaint screen
after resuming. You will resume in your TSTP signal handler.

You may want to look at something like less to see what to do.

>Thanks
>
>Sean Coleman
>coleman@bldrdoc.gov

Are you in Boulder or Gaithersburg?
-- 

	Root Boy Jim Cottrell <rbj@uunet.uu.net>
	I got a head full of ideas
	They're driving me insane