Skip to content

Commit e1af0ee

Browse files
committed
Ignore stdio on Windows when not waiting for process
Previously, when using PowerShell on Windows to open URLs or files without the `wait` option, the parent Node.js process would not exit naturally. Users had to press Ctrl+C to terminate the script. This happened because PowerShell kept stdio streams open, preventing the parent process from exiting even though `subprocess.unref()` was called. Fixes #197
1 parent 281be7d commit e1af0ee

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ const baseOpen = async options => {
214214

215215
// Using Base64-encoded command, accepted by PowerShell, to allow special characters.
216216
options.target = Buffer.from(encodedArguments.join(' '), 'utf16le').toString('base64');
217+
218+
if (!options.wait) {
219+
// PowerShell will keep the parent process alive unless stdio is ignored.
220+
childProcessOptions.stdio = 'ignore';
221+
}
217222
} else {
218223
if (app) {
219224
command = app;

0 commit comments

Comments
 (0)