node/test/sequential/test-child-process-emfile.js
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
The copyright and license notice is already in the LICENSE file.  There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
2015-01-12 15:30:28 -08:00

28 lines
689 B
JavaScript

var common = require('../common');
var assert = require('assert');
var spawn = require('child_process').spawn;
var fs = require('fs');
if (process.platform === 'win32') {
console.log('Skipping test, no RLIMIT_NOFILE on Windows.');
return;
}
for (;;) {
try {
fs.openSync(__filename, 'r');
} catch (err) {
assert(err.code === 'EMFILE' || err.code === 'ENFILE');
break;
}
}
// Should emit an error, not throw.
var proc = spawn(process.execPath, ['-e', '0']);
proc.on('error', common.mustCall(function(err) {
assert(err.code === 'EMFILE' || err.code === 'ENFILE');
}));
// 'exit' should not be emitted, the process was never spawned.
proc.on('exit', assert.fail);