Skip to content

child_process: add public API to unref ipc channel #9313

Closed

Description

@mscdex
  • Version: all
  • Platform: n/a
  • Subsystem: child_process

It would be nice to have a public API to unref() a child process's ipc channel. My use case for this is that I spawn a child process, send some messages back and forth via ipc, then at some point I want to detach the child process. child.unref() is not enough because that only unrefs the C++ ProcessWrap handle. Currently I have to resort to also doing child._channel.unref(). I am not sure if this should be done automatically inside child.unref() or if there should be a separate function or similar.

Activity

  1. added
    child_processIssues and PRs related to the child_process subsystem.
    feature requestIssues requesting new Node.js features.
    on Oct 27, 2016
  2. sam-github commented on Oct 27, 2016

    @sam-github
    Contributor

    I've unrefed _channel, too, for similar reasons, and other reasons.

    I'm not sure ._channel should be quietly unrefed when you unref the ChildProcess. It seems inconsistent to me, because child#unref() doesn't unref the other pipes, like stdout, stderr, or even pipes on descriptors higher than 2.

    I'd prefer for .channel to just be documented as a property that comes into existence when 'ipc' is in the stdio: options, as .stdout and the others are. This would mean changing the name of _channel, aliasing its name so both names exist, or just documenting _channel. I'd prefer aliasing in v7, deprecating in v8, and removing in v9.

  3. added
    docIssues and PRs related to Node.js documentation.
    and removed
    docIssues and PRs related to Node.js documentation.
    on Oct 27, 2016
  4. cjihrig commented on Oct 27, 2016

    @cjihrig
    Contributor

    I like that idea. I've opened #9322 as a potential starting point.

  5. added
    docIssues and PRs related to Node.js documentation.
    and removed
    docIssues and PRs related to Node.js documentation.
    on Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    child_processIssues and PRs related to the child_process subsystem.docIssues and PRs related to Node.js documentation.feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions