Skip to content

Commit b6f17e8

Browse files
mguzmanmedriouk
andauthored
Add comment
Co-authored-by: Evgueni Driouk <edriouk@arm.com>
1 parent 09423d7 commit b6f17e8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

src/vscode-api/runner/process-manager.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ export class ProcessManagerImpl implements ProcessManager {
107107
reject({ code: childProcess.exitCode, error: error });
108108
});
109109

110+
/*
111+
In Node child processes, 'exit' and' close' events mean different lifecycle points:
112+
113+
'exit'
114+
115+
Emitted when the child process itself has ended.
116+
Gives you exit code and signal.
117+
May happen before all stdout and stderr data has been fully flushed/closed.
118+
119+
'close'
120+
121+
Emitted when the process has ended and all stdio streams are closed.
122+
Also provides code and signal.
123+
This is usually the safer event if you need to be sure all output handling is finished.
124+
Typical ordering:
125+
exit first, then close.
126+
127+
Practical rule:
128+
129+
Use exit when you only care that the process terminated.
130+
Use close when you care about complete I/O completion (most
131+
command-runner cases).
132+
133+
We do care about output, therefore 'close' is used here.
134+
*/
110135
childProcess.on('close', code => {
111136
if (code === 0) {
112137
resolve({ code: 0 });

0 commit comments

Comments
 (0)