| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c09eb44 commit 48a353f
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,11 @@ var spawn = require('child_process').spawn; | |||
| 6 | 6 | ||
| 7 | 7 | process.env.HELLO = 'WORLD'; | |
| 8 | 8 | ||
| 9 | + var child; | ||
| 9 | 10 | if (common.isWindows) { | |
| 10 | - var child = spawn('cmd.exe', ['/c', 'set'], {}); | ||
| 11 | + child = spawn('cmd.exe', ['/c', 'set'], {}); | ||
| 11 | 12 | } else { | |
| 12 | - var child = spawn('/usr/bin/env', [], {}); | ||
| 13 | + child = spawn('/usr/bin/env', [], {}); | ||
| 13 | 14 | } | |
| 14 | 15 | ||
| 15 | 16 | var response = ''; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,10 +11,11 @@ env.__proto__ = { | |||
| 11 | 11 | 'FOO': 'BAR' | |
| 12 | 12 | }; | |
| 13 | 13 | ||
| 14 | + var child; | ||
| 14 | 15 | if (common.isWindows) { | |
| 15 | - var child = spawn('cmd.exe', ['/c', 'set'], {env: env}); | ||
| 16 | + child = spawn('cmd.exe', ['/c', 'set'], {env: env}); | ||
| 16 | 17 | } else { | |
| 17 | - var child = spawn('/usr/bin/env', [], {env: env}); | ||
| 18 | + child = spawn('/usr/bin/env', [], {env: env}); | ||
| 18 | 19 | } | |
| 19 | 20 | ||
| 20 | 21 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,9 +24,8 @@ if (common.isWindows) { | |||
| 24 | 24 | return; | |
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | + var server; | ||
| 27 | 28 | if (process.argv[2] === 'child') { | |
| 28 | - var server; | ||
| 29 | - | ||
| 30 | 29 | process.on('message', function removeMe(msg, clusterServer) { | |
| 31 | 30 | if (msg === 'server') { | |
| 32 | 31 | server = clusterServer; | |
@@ -42,7 +41,7 @@ if (process.argv[2] === 'child') { | |||
| 42 | 41 | }); | |
| 43 | 42 | ||
| 44 | 43 | } else { | |
| 45 | - var server = dgram.createSocket('udp4'); | ||
| 44 | + server = dgram.createSocket('udp4'); | ||
| 46 | 45 | var client = dgram.createSocket('udp4'); | |
| 47 | 46 | var child = fork(__filename, ['child']); | |
| 48 | 47 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,11 +4,11 @@ var assert = require('assert'); | |||
| 4 | 4 | var childProcess = require('child_process'); | |
| 5 | 5 | ||
| 6 | 6 | // Child pipe test | |
| 7 | - if (process.argv[2] === 'pipetest') { | ||
| 7 | + if (process.argv[2] === 'pipe') { | ||
| 8 | 8 | process.stdout.write('stdout message'); | |
| 9 | 9 | process.stderr.write('stderr message'); | |
| 10 | 10 | ||
| 11 | - } else if (process.argv[2] === 'ipctest') { | ||
| 11 | + } else if (process.argv[2] === 'ipc') { | ||
| 12 | 12 | // Child IPC test | |
| 13 | 13 | process.send('message from child'); | |
| 14 | 14 | process.on('message', function() { | |
@@ -18,7 +18,7 @@ if (process.argv[2] === 'pipetest') { | |||
| 18 | 18 | } else if (process.argv[2] === 'parent') { | |
| 19 | 19 | // Parent | start child pipe test | |
| 20 | 20 | ||
| 21 | - var child = childProcess.fork(process.argv[1], ['pipetest'], {silent: true}); | ||
| 21 | + const child = childProcess.fork(process.argv[1], ['pipe'], {silent: true}); | ||
| 22 | 22 | ||
| 23 | 23 | // Allow child process to self terminate | |
| 24 | 24 | child._channel.close(); | |
@@ -46,7 +46,7 @@ if (process.argv[2] === 'pipetest') { | |||
| 46 | 46 | }); | |
| 47 | 47 | ||
| 48 | 48 | // testing: do message system work when using silent | |
| 49 | - var child = childProcess.fork(process.argv[1], ['ipctest'], {silent: true}); | ||
| 49 | + const child = childProcess.fork(process.argv[1], ['ipc'], {silent: true}); | ||
| 50 | 50 | ||
| 51 | 51 | // Manual pipe so we will get errors | |
| 52 | 52 | child.stderr.pipe(process.stderr, {end: false}); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,7 +36,7 @@ function parent() { | |||
| 36 | 36 | ||
| 37 | 37 | // then write a bunch more times. | |
| 38 | 38 | for (var i = 0; i < 100; i++) { | |
| 39 | - var buf = new Buffer(BUFSIZE); | ||
| 39 | + const buf = new Buffer(BUFSIZE); | ||
| 40 | 40 | buf.fill('.'); | |
| 41 | 41 | sent += BUFSIZE; | |
| 42 | 42 | child.stdin.write(buf); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,8 @@ | |||
| 2 | 2 | // Flags: --expose_internals | |
| 3 | 3 | ||
| 4 | 4 | require('../common'); | |
| 5 | - var assert = require('assert'); | ||
| 6 | - var _validateStdio = require('internal/child_process')._validateStdio; | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + const _validateStdio = require('internal/child_process')._validateStdio; | ||
| 7 | 7 | ||
| 8 | 8 | // should throw if string and not ignore, pipe, or inherit | |
| 9 | 9 | assert.throws(function() { | |
@@ -16,27 +16,31 @@ assert.throws(function() { | |||
| 16 | 16 | }, /Incorrect value of stdio option/); | |
| 17 | 17 | ||
| 18 | 18 | // should populate stdio with undefined if len < 3 | |
| 19 | - var stdio1 = []; | ||
| 20 | - var result = _validateStdio(stdio1, false); | ||
| 21 | - assert.equal(stdio1.length, 3); | ||
| 22 | - assert.equal(result.hasOwnProperty('stdio'), true); | ||
| 23 | - assert.equal(result.hasOwnProperty('ipc'), true); | ||
| 24 | - assert.equal(result.hasOwnProperty('ipcFd'), true); | ||
| 19 | + { | ||
| 20 | + const stdio1 = []; | ||
| 21 | + const result = _validateStdio(stdio1, false); | ||
| 22 | + assert.equal(stdio1.length, 3); | ||
| 23 | + assert.equal(result.hasOwnProperty('stdio'), true); | ||
| 24 | + assert.equal(result.hasOwnProperty('ipc'), true); | ||
| 25 | + assert.equal(result.hasOwnProperty('ipcFd'), true); | ||
| 26 | + } | ||
| 25 | 27 | ||
| 26 | 28 | // should throw if stdio has ipc and sync is true | |
| 27 | - var stdio2 = ['ipc', 'ipc', 'ipc']; | ||
| 29 | + const stdio2 = ['ipc', 'ipc', 'ipc']; | ||
| 28 | 30 | assert.throws(function() { | |
| 29 | 31 | _validateStdio(stdio2, true); | |
| 30 | 32 | }, /You cannot use IPC with synchronous forks/); | |
| 31 | 33 | ||
| 32 | - const stdio3 = [process.stdin, process.stdout, process.stderr]; | ||
| 33 | - var result = _validateStdio(stdio3, false); | ||
| 34 | - assert.deepStrictEqual(result, { | ||
| 35 | - stdio: [ | ||
| 36 | - { type: 'fd', fd: 0 }, | ||
| 37 | - { type: 'fd', fd: 1 }, | ||
| 38 | - { type: 'fd', fd: 2 } | ||
| 39 | - ], | ||
| 40 | - ipc: undefined, | ||
| 41 | - ipcFd: undefined | ||
| 42 | - }); | ||
| 34 | + { | ||
| 35 | + const stdio3 = [process.stdin, process.stdout, process.stderr]; | ||
| 36 | + const result = _validateStdio(stdio3, false); | ||
| 37 | + assert.deepStrictEqual(result, { | ||
| 38 | + stdio: [ | ||
| 39 | + { type: 'fd', fd: 0 }, | ||
| 40 | + { type: 'fd', fd: 1 }, | ||
| 41 | + { type: 'fd', fd: 2 } | ||
| 42 | + ], | ||
| 43 | + ipc: undefined, | ||
| 44 | + ipcFd: undefined | ||
| 45 | + }); | ||
| 46 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments