daemon.node icon indicating copy to clipboard operation
daemon.node copied to clipboard

Wrong example code for daemon. Printing to stdout without setting it to any file after daemon

Open goelvivek opened this issue 12 years ago • 2 comments

// this code is run twice
// see implementation notes below
console.log(process.pid);

// after this point, we are a daemon
require('daemon')();

//As stdout is closed here. process.pid will not get printed anywhere. 
console.log(process.pid);

goelvivek avatar Jul 07 '13 19:07 goelvivek

process.pid will get printed to whatever stdout option you passed to the daemon function. I believe if you don't pass anything, then yes, it won't go anywhere. However you can pass a file stream and that should work.

defunctzombie avatar Jul 07 '13 23:07 defunctzombie

I am getting following output. If I run sample program.

31343

But according to the example code. It should print two pid.

goelvivek avatar Jul 08 '13 05:07 goelvivek