Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
child_process: fix test implementation for options.detached
Browse files Browse the repository at this point in the history
  • Loading branch information
AvianFlu authored and isaacs committed Jun 11, 2012
1 parent 25e8ea1 commit 2eb181d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 13 additions & 0 deletions test/fixtures/parent-process-nonpersistent.js
@@ -0,0 +1,13 @@

var spawn = require('child_process').spawn,
path = require('path'),
childPath = path.join(__dirname, 'child-process-persistent.js');

var child = spawn(process.execPath, [ childPath ], {
detached: true,
stdio: 'ignore'
});

console.log(child.pid);

child.unref();
19 changes: 13 additions & 6 deletions test/simple/test-child-process-detached.js
Expand Up @@ -24,15 +24,22 @@ var assert = require('assert');
var path = require('path');

var spawn = require('child_process').spawn;
var childPath = path.join(__dirname, '..', 'fixtures', 'child-process-persistent.js');
var childPath = path.join(__dirname, '..', 'fixtures', 'parent-process-nonpersistent.js');
var persistentPid = -1;

var child = spawn(process.execPath, [ childPath ], {
detached: true,
stdio: 'ignore'
var child = spawn(process.execPath, [ childPath ]);

child.stdout.on('data', function (data) {
persistentPid = parseInt(data, 10);
});

process.on('exit', function () {
process.kill(child.pid);
assert.throws(process.kill(child.pid), Error);
assert(persistentPid !== -1);
assert.throws(function () {
process.kill(child.pid);
});
assert.doesNotThrow(function () {
process.kill(persistentPid);
});
});

0 comments on commit 2eb181d

Please sign in to comment.