Skip to content

Instantly share code, notes, and snippets.

@cdolivares
Created December 18, 2014 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdolivares/c462e4be484f48496ebf to your computer and use it in GitHub Desktop.
Save cdolivares/c462e4be484f48496ebf to your computer and use it in GitHub Desktop.

Sometimes processes aren't given a chance to cleanup their state before being killed. This happens when the kernel (Unix) receives a kill -9 command for a process, after which it immediately kills the process without any notification.

Processes spawned from node are pretty easy to zombify:

#create a file to listen on
touch /tmp/zombie.txt
var fs = require("fs");
var spawn = require("child_process").spawn;
/* create a "long running" process */
fs.open("/tmp/zombie.txt", function(err, fd) {
  spawn("tail", ["-f"], {stdio: [fd, null, null]};
};
#issue a kill -9 to the node process so it doesn't have a chance to cleanup
killall -9 node
#verify "long running" process is now zombied
ps -A | grep tail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment