Skip to content
Myr

Detached child process should not kill child - fixes #115 (#117)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sam Verschueren · committed by Sindre Sorhus · parent 79a496a · Browse files · 3 files+28 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+28 added−0 removed

  • other:+28 added−0 removed

3 files+28 added−0 removed

added:fixtures/detach+13 added
1#!/usr/bin/env node2const fs = require('fs');3const execa = require('..');45const fd = fs.openSync(process.argv[2], 'w');67const cp = execa('noop', ['foo'], {8 detached: true,9 stdio: ['ignore', fd]10});11cp.unref();1213process.exit();
modified:index.js+5 added
52 unmodified lines
53 if (opts.preferLocal) {54 opts.env = npmRunPath.env(Object.assign({}, opts, {cwd: opts.localDir}));55 }5657 if (opts.detached) {58 // #11559 opts.cleanup = false;60 }6162 return {63 cmd: parsed.command,64 args: parsed.args,65 opts,
292 unmodified lines
modified:test.js+10 added
487 unmodified lines
488 const result = await getStream(m('max-buffer', ['stdout', '21'], {maxBuffer: 10}).stdout);489490 t.is(result, '....................\n');491});492493test('detach child process', async t => {494 const file = tempfile('.txt');495496 await m('detach', [file]);497498 await delay(2000);499500 t.is(fs.readFileSync(file, 'utf8'), 'foo\n');501});