You get a similar effect in UNIX when you SIGSTOP (CTRL-Z, although this depends on your stty
settings) a process. I believe it stops the process from executing totally and the address space, while not swapped to disk en masse, can be paged out (or discarded if it's reloadable from the executable) due to non-use.
SIGCONT will restart the process.
One possible solution is something we implemented in UNIX a while back. Make the program responsible for its own start and stop, by passing a command-line parameter to it. Secondary copies of the program would not do any real work, they'd only communicate to the primary copy.
So there were four possibilities:
- Run primary copy with 'resume' or no parameter. This would just start the program and let it run.
- Run primary copy with 'pause'. This would start the program which would initialize then send a SIGSTOP signal to itself to halt.
- Run secondary copy with 'resume'. This would send a SIGCONT signal to the primary copy to start it running again. Secondary copies with no parameter would simply complain that a primary was already running then exit.
- Run secondary copy with 'pause'. This would send a SIGSTOP signal to the primary copy to make it pause.
We used shared memory for communicating with the primary since there were many other things a secondary could pass to the primary. But if all you want is stop and start instructions, I'd go for storing the PID in a known file and checking to make sure the process name is valid.
This gives you a nice idiom for a program that can pause and restart just by seemingly running it again with different parameters.