1'use strict'; 2const common = require('../common'); 3// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. 4if (common.isSunOS || common.isWindows || common.isAIX) 5 common.skip('cannot rmdir current working directory'); 6if (!common.isMainThread) 7 common.skip('process.chdir is not available in Workers'); 8 9const assert = require('assert'); 10const fs = require('fs'); 11const spawn = require('child_process').spawn; 12 13const tmpdir = require('../common/tmpdir'); 14 15const dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`; 16tmpdir.refresh(); 17fs.mkdirSync(dirname); 18process.chdir(dirname); 19fs.rmdirSync(dirname); 20 21const proc = spawn(process.execPath, ['--interactive']); 22proc.stdout.pipe(process.stdout); 23proc.stderr.pipe(process.stderr); 24proc.stdin.write('require("path");\n'); 25proc.stdin.write('process.exit(42);\n'); 26 27proc.once('exit', common.mustCall(function(exitCode, signalCode) { 28 assert.strictEqual(exitCode, 42); 29 assert.strictEqual(signalCode, null); 30})); 31