diff --git a/lib/child_process.js b/lib/child_process.js index cef093a0b74..b3e6383c752 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -153,6 +153,12 @@ exports.fork = function(modulePath, args, options) { args = args ? args.slice(0) : []; args.unshift(modulePath); + if (options.thread) { + if (!process.features.isolates) { + throw new Error('node compiled without isolate support'); + } + } + if (options.stdinStream) { throw new Error('stdinStream not allowed for fork()'); } diff --git a/test/simple/test-child-process-fork.js b/test/simple/test-child-process-fork.js index 41cc28c72e4..ea99ae7704b 100644 --- a/test/simple/test-child-process-fork.js +++ b/test/simple/test-child-process-fork.js @@ -24,7 +24,13 @@ var common = require('../common'); var fork = require('child_process').fork; var args = ['foo', 'bar']; -var n = fork(common.fixturesDir + '/child-process-spawn-node.js', args); +var options = { + thread: process.TEST_ISOLATE ? true : false +}; + +var n = fork(common.fixturesDir + '/child-process-spawn-node.js', + args, + options); assert.deepEqual(args, ['foo', 'bar']); var messageCount = 0; diff --git a/test/simple/test-isolates2.js b/test/simple/test-isolates2.js new file mode 100644 index 00000000000..1823b8fe76c --- /dev/null +++ b/test/simple/test-isolates2.js @@ -0,0 +1,13 @@ +// Skip this test if Node is not compiled with isolates support. +if (!process.features.isolates) return; + +var assert = require('assert'); + +// This is the same test as test-child-process-fork except it uses isolates +// instead of processes. process.TEST_ISOLATE is a ghetto method of passing +// some information into the other test. +process.TEST_ISOLATE = true; +require('./test-child-process-fork'); + +var numThreads = process.binding('isolates').count(); +assert.ok(numThreads > 1);