Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run Zotero/Firefox, they often crash and I am left with zombie processes; after this I cannot open new instances of Zotero or Firefox. I want to get rid of these zombie processes rather than rebooting, so for <pid> of the zombie process,

$ ps -p <pid> -o ppid=

gives me the <parent_pid> and

ps aux | awk -v PID=<parent_pid> '$2 == PID {print $0}'

tells me the parent process is /sbin/launchd for user crippledlambda.

Is there a way to restart this without killing my system?

sudo kill -1 <parent_pid>

does nothing. I've tried writing this in a script and running it with sudo:

for i in `launchctl list | grep launchd | awk -v PID=<parent_pid> '$1==PID { print $NF }'`; do `launchctl stop $i && launchctl start $i` ; done

and this obviously(?) leaves me with an unresponsive gray screen so I have to reboot anyway. Thanks in advance for your suggestions.

share|improve this question
    
Why are you killing launchd instead of the leftover processes themselves? launchd is a core part of the user session; even if you could restart it, the new instance would not be the parent of all the other processes it's responsible for... things like the Finder, Dock, etc. –  Gordon Davisson Apr 21 '13 at 4:13
    
@Gordon, you cannot kill zombie processes so you have to go after the parent, unless I'm missing something. –  crippledlambda Apr 23 '13 at 12:13
    
Are they true zombies (i.e. processes that have exited, but whose exit status has not been read)? If they are, something much deeper is wrong, since launchd should always read its children's exit statuses immediately. If they aren't truly zombies, then you should be killing them. In either case, killing launchd is going to cause more problems than it solves. –  Gordon Davisson Apr 23 '13 at 15:55

1 Answer 1

The proper way to stop and start launch daemons is launchctl unload.

For example:

You can stop a launch daemon service using the unload subcommand of launchctl.

$ sudo launchctl unload /System/Library/LaunchDaemons/<daemon name>.plist

To start a disabled or stopped launch daemon:

$ sudo launchctl load /System/Library/LaunchDaemons/<daemon name>.plist

★ Be careful with disabling launch daemons haphazardly - especially the official Apple ones; it can potentially make your system unbootable until you start in safe mode and manually re-enable them. You don't kill a launchctl like a normal process because it can potentially kill your system like you've experienced.

> more info on launchctl here. (Apple launchctl man page)

share|improve this answer
    
Sorry, is that com.apple.bsd.launchdadd.plist? I don't see launchd exactly. And thanks for the warning... –  crippledlambda Apr 23 '13 at 12:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.