Skip to content

Rename ChildProcess exec and fork to something which is not entirely confusing to system developers #224

Description

@guss77

The ChildProcess module's exec and fork methods sound a bit similar to the system calls of that name, but behave entirely differently. I've been bit by this a few times already.

To reduce confusion and make it easier to understand what is going on, these should be renamed to something like similarly functional methods in other environements (for example exec I believe is very similar to system, OTOH I'm not sure what I would do with fork).

Also, it would be great if IO.js will add implementation for fork and exec system calls so that developers can take advantage of these powerfull primitives to create their own multi-process mechanisms.

Activity

  1. qfox commented on Dec 31, 2014

    @qfox

    Totally agreed. But personally I'm already accustomed to this naming ;-(

  2. DavidSouther commented on Dec 31, 2014

    @DavidSouther

    System programers should change their process execution model to be something sensible ;)

    Only sort of J/K - the unix process model is not exactly "intuitive" IMHO. But I totally agree that the current names in ChildProcess are inappropriate.

  3. sam-github commented on Dec 31, 2014

    @sam-github
    Contributor

    I found it confusing, too, but any suggestion of changing should include a proposal for new names! I suspect they are what they are because no one could think of better at the time.

  4. DavidSouther commented on Dec 31, 2014

    @DavidSouther

    @sam-github Fair enough.

    • ChildProcess.spawn - as current; equivalent to posix fork / exec.
    • ChildProcess.execute - as ChildProcess.exec; delegates to a POSIX shell.
    • ChildProcess.start - As ChildProcess.execFile; delegates to a POSIX shell with a -c flag.
    • ChildProcess.run - As ChildProcess.fork; shortcut to starting a new v8 node/iojs process.
  5. sam-github commented on Dec 31, 2014

    @sam-github
    Contributor

    Hm, well

    • execute is just longer than exec, but might guide people away from thinking it's equivalent to exec(2). BTW, it doesn't delegate to a POSIX shell on Windows, its cmd.exe there, which is most of the value
    • start: doesn't use a shell on any system, its purpose in life is not use a shell, it directly spawns the executable file. This name, start, fails to indicate that it has basically the same interface as exec/execute, in that it runs to completion and returns the output, and differs only in not having an intermediate shell.
    • run: isn't any more descriptive than fork(), but at least doesn't leave people thinking it is fork(2) equivalent

    I hated the names at first, too, but at this point, I think the biggest benefit would be an introduction added to the child_process docs, summarizing the use-cases for the various functions, with particular emphasis on portability (why spawn and execFile won't work for scripts, such as node scripts, on Windows).

  6. qfox commented on Dec 31, 2014

    @qfox

    The best thread is here ;-D 🎄

    Agree. Looks like we need some documentation to understand all cases we have.

  7. garthk commented on Jan 1, 2015

    @garthk

    With @sam-github: unless we're suddenly embracing breaking API changes, fixing this with documentation is a good approach.

    Is there some general principles document from the TC giving the relative priority of "not breaking" and "forward"?

  8. dashed commented on Jan 3, 2015

    @dashed

    +1 for documentation clarification.

  9. trevnorris commented on Jan 16, 2015

    @trevnorris
    Contributor

    A documentation fix sounds like the appropriate solution. We won't be breaking API any time soon, so we're stuck with the names.

  10. added
    child_processIssues and PRs related to the child_process subsystem.
    docIssues and PRs related to Node.js documentation.
    on Jan 16, 2015
  11. Trott commented on May 17, 2015

    @Trott
    Member

    Is a simple one-line note like done here sufficient? https://github.com/nodejs/io.js/pull/1718/files

    Or should the differences be explicitly stated? (And if so, is that a requirement or merely something that would be done ideally but not strictly necessary?)

  12. guss77 commented on May 17, 2015

    @guss77
    Author

    I would think that something with more content would be preferable, noting
    the major differences without giving uninterested parties an unrequested
    crash course in system programming. Something like:

    child_process.exec() is unrelated to the exec() system call in
    Unix-like operating systems. This call is similar to the system() Unix
    call in that it does not replace the existing process and uses a shell to
    execute the command.

    and

    child_process.fork() is unrelated to the fork() system call in
    Unix-like operating systems. This call is similar to the "fork-exec"
    technique used in Unix system programs.

    On Sun, May 17, 2015 at 5:27 PM, Rich Trott notifications@github.com
    wrote:

    Is a simple one-line note like done here sufficient?
    https://github.com/nodejs/io.js/pull/1718/files

    Or should the differences be explicitly stated? (And if so, is that a
    requirement or merely something that would be done ideally but not strictly
    necessary?)

    —
    Reply to this email directly or view it on GitHub
    #224 (comment).

    Oded

  13. silverwind commented on May 20, 2015

    @silverwind
    Contributor

    Fixed by 86dd244

  14. added a commit that references this issue on Aug 20, 2019
  15. added a commit that references this issue on Aug 21, 2019
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.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions