Skip to content

Child process not receiving messages when created with an --eval argument to child_process.fork #8944

@nathansobo

Description

@nathansobo
  • Electron version: 1.6.3
  • Operating system: macOS 10.12.3

In this example repository, I'm creating two child processes via child_process.fork, one using --eval and the other via a module path to a file containing essentially the same source as I'm evaling in the first case. The code is as follows:

const sourceToEval = `
  console.log('starting child process 1')
  process.on('message', m => console.log('child 1 got message', m))
  console.log('waiting for messages in child process 1...')
`

const {fork} = require('child_process')

console.log('forking child process 1 (using --eval)')
const child1  = fork('--eval', [sourceToEval])
console.log('done forking child 1, sending message')
child1.send('hello from your parent')

console.log('forking child process 1 (using module path)')
const child2  = fork('./child')
console.log('done forking child r, sending message')
child2.send('hello from your parent')

Expected behavior

I would expect to see output from both child processes on stdout of the parent when they receive messages.

Actual behavior

I only see output from the process forked with a module path.

How to reproduce

Run the app at https://github.com/atom/electron-child-process-test

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions