Skip to content

Commit

Permalink
Detach the child process when waiting is false
Browse files Browse the repository at this point in the history
On platforms that use xdg-open, if waiting option is false set stdio to 'ignore'
and detached to true so that the xdg-open process is completely detached from
the parent and it is able to continue running after the parent exits.
  • Loading branch information
GAumala committed Sep 14, 2017
1 parent eb99a73 commit 4e4a759
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ module.exports = (target, opts) => {
// `xdg-open` will block the process unless
// stdio is ignored even if it's unref'd
cpOpts.stdio = 'ignore';
// `xdg-open` will NOT stay running in the background
// after the parent exits unless it is detached from
// the parent AND it ignores the parent's stdio file descriptor
cpOpts.detached = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Type: `Object`
Type: `boolean`<br>
Default: `true`

Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app, and the app is completely detached from the node process that spawned it.

On Windows you have to explicitly specify an app for it to be able to wait.

Expand Down

0 comments on commit 4e4a759

Please sign in to comment.