summaryrefslogtreecommitdiff
path: root/test/parallel/test-child-process-fork-close.js
blob: 12b64cc4ff82acd57d774d890d68cd7236548ce6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
var assert = require('assert'),
    common = require('../common'),
    fork = require('child_process').fork,
    fork = require('child_process').fork;

var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js');

var gotMessage = false,
    gotExit = false,
    gotClose = false;

cp.on('message', function(message) {
  assert(!gotMessage);
  assert(!gotClose);
  assert.strictEqual(message, 'hello');
  gotMessage = true;
});

cp.on('exit', function() {
  assert(!gotExit);
  assert(!gotClose);
  gotExit = true;
});

cp.on('close', function() {
  assert(gotMessage);
  assert(gotExit);
  assert(!gotClose);
  gotClose = true;
});

process.on('exit', function() {
  assert(gotMessage);
  assert(gotExit);
  assert(gotClose);
});