There might be an easier way, using fuser I have created a situation here, where node.js has spawned a process and died
xxx@ubuntu:~/node$ node index.js
Server has started
Request for / received.
About to route a request for /
Request handler 'start' was called
/home/xxx/node/requestHandlers.js:27
response.write(body);
^
ReferenceError: body is not defined
at Object.start (/home/xxx/node/requestHandlers.js:27:17)
at route (/home/xxx/node/node/router.js:4:18)
at Server.onRequest (/home/xxx/node/node/server.js:9:3)
at Server.emit (events.js:70:17)
at HTTPParser.onIncoming (http.js:1478:12)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1374:22)
at TCP.onread (net.js:348:27)
If I run fuser <directory from which node started - example fuser /opt/node, I see the pids I created
xxxx@ubuntu:~$ fuser node
node: 16490c 16491
Just to be double sure - running ps, I can see the matching pids
xxxx@ubuntu:~$ ps -ef | grep find | grep -v grep
xxxx 16490 1 0 17:39 pts/0 00:00:00 /bin/sh -c find / -name 'moo'
xxxx 16491 16490 21 17:39 pts/0 00:00:04 find / -name moo
I can run fuser -k /opt/node to kill and clean up the pids started from /opt/node. I personally use fuser regularly at work and home to clean up any leftover processes.
I have tested fuser on ubuntu and solaris.
NOTE: The only thing you need to be careful about is if there is an SSH session on that directory it will be nuked along with any other process started from that directory.