Node js spawn function

If you execute the code below with Node.js installed from snap and apply what I said in the comment, it doesn’t work. But it works if you install Node from other sources. It’s probably because snap is sandboxing the process, and somehow It can’t do IPC with the child process, maybe they can’t access the same file descriptors! I’m not sure about the reason.

As this is not the expected behavior I thought something else needs to be fixed.

const spawn = require('child_process').spawn;

if (process.argv[2] === 'child') {
  let net = require('net');
  let pipe = new net.Socket({ fd: 3 });
} else {
  let child = spawn(process.execPath, [__filename, 'child'], {
    // changing process.execPath to 'node' breaks the ipc
    stdio: [null, null, null, 'pipe'],
  child.stdio[3].on('data', (data) => {
    if (data.toString() === 'killme') {

I think you’re being hit by: A workaround for is described in

A workaround has been sketched out here: But there hasn’t been much progress so far.