I cannot get stdout from child process


#1

I can’t get stdout in a child process to send anything back to my parent process stdout. I’ve tried spawn, fork, and BufferedNodeProcess. I’ve specified the stdio several different ways, but the default should work. Here is my package main …

{BufferedNodeProcess} = require 'atom'
module.exports =
  activate: (state) ->
    atom.commands.add 'atom-workspace', 'proc:toggle': => 
      console.log 'before BufferedNodeProcess'
      @child = new BufferedNodeProcess
        command: './lib/child.js'
        args: []
        stdout: (evt) => console.log 'stdout', evt
        stderr: (evt) => console.log 'stderr', evt
        exit:   (evt) => console.log 'exit',   evt
      console.log 'after BufferedNodeProcess:', @child

Here is the child process code, child.js. …

fs = require('fs');
fs.writeFileSync('./lib/child-out.txt', 'child.js writes hello to ./lib/child-out');
console.log('child.js says hello to console');

Here is the atom console output when running proc:toggle

before BufferedNodeProcess
after BufferedNodeProcess: BufferedNodeProcess
exit 0

I know the child is running properly. I’m getting the correct output in child-out.txt and I’m getting the exit event with 0.

Any ideas?

Versions

  • Atom: 0.144.0
  • Atom-Shell: 0.19.1
  • OS: Microsoft Windows 8.1 Pro with Media Center
  • Misc
    • eapme e0.109.0e
    • enpme e1.4.4e
    • enodee e0.10.32e
    • epythone e2.7.5e
    • egite e1.7.11.msysgit.1e
    • evisual studioe e2013e

This report was created in the Atom editor using the package bug-report version 0.4.1.

Edit: I was finally able to get spawn to work by using the stdout events like @child.stdout.on 'data', (data) ->. But it shouldn’t be this hard.