2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-02-18 03:43:29 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
2015-07-29 17:18:04 +05:30
|
|
|
if (common.isWindows) {
|
2015-07-06 03:24:12 +00:00
|
|
|
console.log('1..0 # Skipped: platform not supported.');
|
2015-02-18 03:43:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.argv[2] === 'child') {
|
|
|
|
process.stdout.write('stdout', function() {
|
|
|
|
process.stderr.write('stderr', function() {
|
|
|
|
process.exit(42);
|
|
|
|
});
|
|
|
|
});
|
2015-02-25 10:40:33 +01:00
|
|
|
return;
|
2015-02-18 03:43:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run the script in a shell but close stdout and stderr.
|
2016-02-21 21:19:32 -08:00
|
|
|
var cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`;
|
2015-02-18 03:43:29 +01:00
|
|
|
var proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' });
|
|
|
|
|
|
|
|
proc.on('exit', common.mustCall(function(exitCode) {
|
|
|
|
assert.equal(exitCode, 42);
|
|
|
|
}));
|