MetallicPriest
MetallicPriest

Reputation: 30805

Suspend forked process at startup

I want to suspend (pause) a forked process at startup and resume it later on. Is there any way to do that with POSIX or Solaris.

Upvotes: 0

Views: 957

Answers (3)

MetallicPriest
MetallicPriest

Reputation: 30805

I did it by using a semaphore and a signal handler. To wake up the child, the parent process sends a signal to the child process which in turn posts the semaphore from within the signal handler. The child, which was waiting on that semaphore, then wakes up.

Upvotes: 0

Mihran Hovsepyan
Mihran Hovsepyan

Reputation: 11108

Why not just call pause() in code of child process after fork?

Upvotes: 4

Michael Aaron Safyan
Michael Aaron Safyan

Reputation: 95579

You could send your process SIGSTOP, then resume with SIGCONT.

Upvotes: -1

Related Questions