4 ms·
Btw, it is possible to suspend Unix processes from the command line by sending them the SIGSTOP signal. ;playing a song with iTunes $ ps ax | grep iTunes
by waterhouse 15y ago
Btw, it is possible to suspend Unix processes from the command line by sending them the SIGSTOP signal.
;playing a song with iTunes
$ ps ax | grep iTunes
401 ?? S 5:29.21 /Applications/iTunes.app/Contents/MacOS/iTunes -psn_0_213044
$ kill -STOP 401
;the song stops playing, and iTunes's CPU usage drops to zero
$ kill -CONT 401
;the song resumes exactly where it was
I've done this to, say, Firefox, and resumed it sometime later with no ill effects that I've been able to detect. (Firefox usually has a secondary Flash plugin process; the interaction between the two when one is suspended is kind of interesting, but seemingly benign.)
I've found this useful when I've wanted to throttle some application's CPU/other resource usage (usually on a laptop) but didn't want to completely quit it. Also it's just kind of awesome.
- ianso 15y agoThat is awesome! I wonder if the process could be read out via procfs and continued elsewhere?
- gwern 15y agoI dunno about procfs, but one Linux implementation of https://en.wikipedia.org/wiki/Application_checkpointing https://en.wikipedia.org/wiki/Application_checkpointing is http://cryopid.berlios.de/ http://cryopid.berlios.de/ or apparently http://dmtcp.sourceforge.net/ http://dmtcp.sourceforge.net/
- nemoniac 15y agoThere has been a whole bunch of approaches to this over the years, some of them kernel level and others in user space. Search for "checkpoint restart" to find some links or start here: http://checkpointing.org/ http://checkpointing.org/ It's all pretty dated though. I did some work on it years ago but it's no longer maintained http://www.science.uva.nl/research/scs/Software/ckpt/ckpt.html http://www.science.uva.nl/research/scs/Software/ckpt/ckpt.ht...
- rcfox 15y agoYou could also do: kill -STOP `pidof iTunes` (I have no idea if pidof is included in OSX. It exists in Debian systems though!)
- jpitz 15y agoPidof does not seem to be included in 10.6. HomeBrew has it, MacPorts could not find it.
- waterhouse 15y ago"killall -STOP iTunes" works well enough too.