11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci// Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX.
41cb0ef41Sopenharmony_ciif (common.isSunOS || common.isWindows || common.isAIX || common.isIBMi)
51cb0ef41Sopenharmony_ci  common.skip('cannot rmdir current working directory');
61cb0ef41Sopenharmony_ciif (!common.isMainThread)
71cb0ef41Sopenharmony_ci  common.skip('process.chdir is not available in Workers');
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciconst assert = require('assert');
101cb0ef41Sopenharmony_ciconst fs = require('fs');
111cb0ef41Sopenharmony_ciconst spawn = require('child_process').spawn;
121cb0ef41Sopenharmony_ciconst fixtures = require('../common/fixtures');
131cb0ef41Sopenharmony_ciconst tmpdir = require('../common/tmpdir');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst dirname = `${tmpdir.path}/cwd-does-not-exist-${process.pid}`;
161cb0ef41Sopenharmony_ciconst abspathFile = fixtures.path('a.js');
171cb0ef41Sopenharmony_citmpdir.refresh();
181cb0ef41Sopenharmony_cifs.mkdirSync(dirname);
191cb0ef41Sopenharmony_ciprocess.chdir(dirname);
201cb0ef41Sopenharmony_cifs.rmdirSync(dirname);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ciconst proc = spawn(process.execPath, ['-r', abspathFile, '-e', '0']);
241cb0ef41Sopenharmony_ciproc.stdout.pipe(process.stdout);
251cb0ef41Sopenharmony_ciproc.stderr.pipe(process.stderr);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciproc.once('exit', common.mustCall(function(exitCode, signalCode) {
281cb0ef41Sopenharmony_ci  assert.strictEqual(exitCode, 0);
291cb0ef41Sopenharmony_ci  assert.strictEqual(signalCode, null);
301cb0ef41Sopenharmony_ci}));
31