#!/usr/bin/env node

'use strict';

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

if (process.send) {
  require('./test-spawn-a-child.js');
  return;
}

var child = spawn(
  process.execPath, [ __filename, 'argvx', 'argvy' ],
  { stdio: [ 'inherit', 'inherit', 'inherit', 'ipc' ] }
);

function ifError (error) {
  if (error) {
    console.log('child.send.error', error);
  }
}

child.on('message', function (value) {
  console.log(value.toString());
  if ((process.version.slice(1, 3) | 0) > 0) {
    child.send(value, ifError);
  } else {
    child.send(value);
  }
});

child.send(2);

child.on('exit', function (code) {
  console.log('Child exited with code', code);
});

#!/usr/bin/env node

'use strict';

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

if (process.send) {
  require('./test-spawn-a-child.js');
  return;
}

var child = spawn(
  process.execPath, [ __filename, 'argvx', 'argvy' ],
  { stdio: [ 'inherit', 'inherit', 'inherit', 'ipc' ] }
);

child.on('message', function (value) {
  console.log(value.toString());
  child.send(value, function (error) {
    if (error) {
      console.log('child.send.error', error);
    }
  });
});

child.send(2);

child.on('exit', function (code) {
  console.log('Child exited with code', code);
});

Revert "take node0 child.send args into consideration"
Revert "take node0 child.send args into consideration"

This reverts commit eb0cb99d4c78046db8024d3bb748a9af3759c2ab.
