John
John

Reputation: 43

How do I programmatically suspend/resume process and its children on Mac OS X?

I am trying to control a spawned task that in my case is a bash script that then runs another program. I wish to be able to suspend and resume those processes. My program is meant to be able to spawn any task so I cannot presume to know if the spawned process will spawn another process or processes.

I launched the process using NSTask and can control the original process but it does not affect the child processes.

Any help would be appreciated.

Upvotes: 2

Views: 2304

Answers (1)

tripleee
tripleee

Reputation: 189739

The SIGSTOP signal does this. With a negative PID, the kill command will send it to the entire process group.

kill -s SIGSTOP -$pid

Send a SIGCONT to resume.

Upvotes: 9

Related Questions