Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a lot of defunct sh processes running. When I execute this command, to count them:

ps -ax | grep sh | wc -l

It says I’ve got 2655 at the moment. Do they use up any system resources? I have no idea where they’re coming from, this is the only data the ps command gives me:

32637 ?        Z      0:00 [sh] <defunct>

Does anyone know how to stop this from happening, and how to kill these processes?

share|improve this question
A problem can occur if you get so many zombie processes that the PIDs run out. You currently have 32767 PIDs, though, and they are reused once a process releases the PID. With no PIDs left, new processes cannot start (or they kick old processes out. I actually don't know which, but I believe it is the first option. Couldn't find the information quickly right now, though). – Daniel Andersson Aug 25 '12 at 20:01
up vote 4 down vote accepted
lsof -p 32637

will give you more information on the process. Looking at the parent process that is causing this can help prevent it.

share|improve this answer
Thanks, some defunct processes didn't have any information, others showed files from an sshfs mount were open. At least I know where to look now. – skerit Aug 30 '12 at 19:52

Do they use up any system resources?

I believe not much other than a slot in the process table.

how to stop this from happening?

Identify what is their parent process that spawned them and find out why it isn't waiting for its children to die (and hence not reaping them)

how to kill these processes?

You can't kill something that is already dead. If the parent is killed, init should eventually inherit them and reap them for you.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .