Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 19, 2012 01:42
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 isaacs/3915800 to your computer and use it in GitHub Desktop.
Save isaacs/3915800 to your computer and use it in GitHub Desktop.
$ cat package.json
{
"name": "npm-test-start",
"version": "0.0.0",
"description": "just an npm test",
"scripts": {
"test": "exit 0",
"start": "node server.js"
},
"repository": "",
"author": "",
"license": "BSD"
}
$ cat server.js
// just a thing to keep it alive.
setInterval(function () {
console.log('still alive')
}, 1000)
$ npm start
> npm-test-start@0.0.0 start /Users/isaacs/dev/js/npm/test/packages/npm-test-start
> node server.js
still alive
still alive
still alive
^C
@jfhbrook
Copy link

Using the same test case:

josh@onix:/tmp/test-case$ npm start
npm WARN package.json npm-test-start@0.0.0 No README.md file found!

> npm-test-start@0.0.0 start /tmp/test-case
> node server.js

still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive

But then in another window:

josh@onix:/tmp/test-case$ ps aux | grep npm
josh      2002  2.6  0.5 735092 19908 pts/3    Sl+  18:47   0:00 npm                                         
josh@onix:/tmp/test-case$ ps aux | grep node
josh      2005  0.0  0.0   4404   624 pts/3    S+   18:47   0:00 sh -c node server.js
josh      2006  0.3  0.1 655780  7800 pts/3    Sl+  18:47   0:00 node server.js
josh      2075  0.0  0.0  35544   928 pts/6    S+   18:47   0:00 grep --color=auto node
josh      8792  0.0  0.1 661464  6016 pts/0    Sl+  Oct17   0:06 node /home/josh/bin/respondtobeepsmorequietly

The processes to look at here are 2002 (npm), 2005 (sh -c) and 2006 (node).

So, then I kill npm:

josh@onix:/tmp/test-case$ kill 2002
josh@onix:/tmp/test-case$ ps aux | grep npm
josh      2077  0.0  0.0  35544   924 pts/6    S+   18:48   0:00 grep --color=auto npm

so npm's gone...but what about my node process?

josh@onix:/tmp/test-case$ ps aux | grep node
josh      2005  0.0  0.0   4404   624 pts/3    S    18:47   0:00 sh -c node server.js
josh      2006  0.0  0.1 655780  7800 pts/3    Sl   18:47   0:00 node server.js
josh      2079  0.0  0.0  35544   928 pts/6    S+   18:48   0:00 grep --color=auto node
josh      8792  0.0  0.1 661464  6016 pts/0    Sl+  Oct17   0:06 node /home/josh/bin/respondtobeepsmorequietly

It's still there. And, in the first window, I see:

still alive
still alive
still alive
still alive
still alive
still alive
josh@onix:/tmp/test-case$ still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive
still alive

@isaacs
Copy link
Author

isaacs commented Oct 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment