-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: add subprocess.ref() and subprocess.unref() methods #22220
Conversation
doc/api/child_process.md
Outdated
@@ -1094,6 +1094,27 @@ console.log(`Spawned child pid: ${grep.pid}`); | |||
grep.stdin.end(); | |||
``` | |||
|
|||
### subprocess.ref() | |||
<!-- YAML | |||
added: v0.7.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be 0.7.10
? And same for unref
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Will fix.
doc/api/child_process.md
Outdated
--> | ||
|
||
By default, the parent will wait for the detached child to exit. To prevent | ||
the parent from waiting for a given `subprocess`, use the `subprocess.unref()` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe `for a given `subprocess` to exit`
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made
doc/api/child_process.md
Outdated
the parent from waiting for a given `subprocess`, use the `subprocess.unref()` | ||
method. Doing so will cause the parent's event loop to not include the child in | ||
its reference count, allowing the parent to exit independently of the child, | ||
unless there is an established IPC channel between the child and parent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
between the child and the parent
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change made
cb9e2d8
to
ebbf8e6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
A few minor nits below.
doc/api/child_process.md
Outdated
|
||
Calling `subprocess.ref()` after making a call to `subprocess.unref()` will | ||
restore the removed reference count for the child process, allowing the parent | ||
process to wait for the child process to exit before itself exiting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ... before exiting itself.
reads better, IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
doc/api/child_process.md
Outdated
--> | ||
|
||
Calling `subprocess.ref()` after making a call to `subprocess.unref()` will | ||
restore the removed reference count for the child process, allowing the parent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: forcing
instead of allowing
seems to be the right word here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
doc/api/child_process.md
Outdated
|
||
Calling `subprocess.ref()` after making a call to `subprocess.unref()` will | ||
restore the removed reference count for the child process, allowing the parent | ||
process to wait for the child process to exit before itself exiting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: given the context, usage of the word process
to describe parent
and child
can be safely omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
ebbf8e6
to
6b97a9a
Compare
Node.js Collaborators, please, add 👍 here if you approve fast-tracking. |
Landed in 7b1f3a4 |
PR-URL: #22220 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]>
PR-URL: #22220 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Bryan English <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]>
This PR documents the
subprocess.ref()
andsubprocess.unref()
methods. The latter method does appear in the documentation as a side node in theoptions.detached
section while the prior does not appear anywhere.Neither takes an argument nor has a return. I copied the documentation for
unref
from the existingdetached
docs. This is now redundant, perhaps the content should be removed fromdetached
and a link be added toref
.The introduction version number should be correct, see
git log v0.7.10
to confirm.Checklist