GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: test and docs for detached fork process · nodejs/node@5966dbe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • child_process.md
  • test
    • fixtures
      • parent-process-nonpersistent-fork.js
    • parallel
      • test-child-process-fork-detached.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/child_process.md‎

Copy file name to clipboardExpand all lines: doc/api/child_process.md
+3Lines changed: 3 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ changes:
325325
* `args` {string[]} List of string arguments.
326326
* `options` {Object}
327327
* `cwd` {string} Current working directory of the child process.
328+
* `detached` {boolean} Prepare child to run independently of its parent
329+
process. Specific behavior depends on the platform, see
330+
[`options.detached`][]).
328331
* `env` {Object} Environment key-value pairs.
329332
* `execPath` {string} Executable used to create the child process.
330333
* `execArgv` {string[]} List of string arguments passed to the executable.
Collapse file

‎test/fixtures/parent-process-nonpersistent-fork.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const fork = require('child_process').fork;
2+
const path = require('path');
3+
4+
const child = fork(
5+
path.join(__dirname, 'child-process-persistent.js'),
6+
[],
7+
{ detached: true, stdio: 'ignore' }
8+
);
9+
10+
console.log(child.pid);
11+
12+
child.unref();
Collapse file

‎test/parallel/test-child-process-fork-detached.js‎

Copy file name to clipboard
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const fork = require('child_process').fork;
5+
const fixtures = require('../common/fixtures');
6+
7+
const nonPersistentNode = fork(
8+
fixtures.path('parent-process-nonpersistent-fork.js'),
9+
[],
10+
{ silent: true });
11+
12+
let childId = -1;
13+
14+
nonPersistentNode.stdout.on('data', (data) => {
15+
childId = parseInt(data, 10);
16+
nonPersistentNode.kill();
17+
});
18+
19+
process.on('exit', () => {
20+
assert.notStrictEqual(childId, -1);
21+
// Killing the child process should not throw an error
22+
process.kill(childId);
23+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.