Skip to content

Commit b2834ce

Browse files
bcoeaddaleax
authored andcommitted
process: fix call process.reallyExit, vs., binding
Some user-land modules, e.g., nyc, mocha, currently rely on patching process.reallyExit. PR-URL: #25655Fixes: #25650 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 55768c0 commit b2834ce

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎lib/internal/process/per_thread.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ function wrapProcessMethods(binding) {
149149
process._exiting=true;
150150
process.emit('exit',process.exitCode||0);
151151
}
152-
binding.reallyExit(process.exitCode||0);
152+
// FIXME(joyeecheung): This is an undocumented API that gets monkey-patched
153+
// in the user land. Either document it, or deprecate it in favor of a
154+
// better public alternative.
155+
process.reallyExit(process.exitCode||0);
153156
}
154157

155158
functionkill(pid,sig){
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
require('../common');
3+
constassert=require('assert');
4+
5+
// ensure that the reallyExit hook is executed.
6+
// see: https://github.com/nodejs/node/issues/25650
7+
if(process.argv[2]==='subprocess'){
8+
process.reallyExit=function(){
9+
console.info('really exited');
10+
};
11+
process.exit();
12+
}else{
13+
const{ spawnSync }=require('child_process');
14+
constout=spawnSync(process.execPath,[__filename,'subprocess']);
15+
constobserved=out.output[1].toString('utf8').trim();
16+
assert.strictEqual(observed,'really exited');
17+
}

0 commit comments

Comments
 (0)