How to use the child_process._forkChild function in child_process

To help you get started, we’ve selected a few child_process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github luminati-io / luminati-proxy / lib / cluster_route.js View on Github external
E._create_ipc_channel = fd=>{
    // save process so we can restore it after _forkChild() changed it
    let original_process = process;
    try {
        let channel = global.process = new EventEmitter();
        child_process._forkChild(fd);
        // fixing node bug:
        // recv handle loss when msg is splitted into multiple chunks
        let pipe = channel._channel, orig_onread = pipe.onread, last_handle;
        pipe.onread = (nread, pool, handle)=>{
            last_handle = handle||last_handle;
            return orig_onread.call(pipe, nread, pool, last_handle);
        };
        channel.on('internalMessage', (msg, handle)=>{
            if (handle===last_handle)
                last_handle = null;
        });
        return channel;
    } finally { global.process = original_process; }
};
E.create_socket_pair = ()=>etask(function*create_socket_pair(){
github graalvm / graaljs / graal-nodejs / lib / internal / bootstrap / pre_execution.js View on Github external
function setupChildProcessIpcChannel() {
  if (process.env.NODE_CHANNEL_FD) {
    const assert = require('internal/assert');

    const fd = parseInt(process.env.NODE_CHANNEL_FD, 10);
    assert(fd >= 0);

    // Make sure it's not accidentally inherited by child processes.
    delete process.env.NODE_CHANNEL_FD;

    require('child_process')._forkChild(fd);
    assert(process.send);
  }
}
github graalvm / graaljs / lib / internal / bootstrap / pre_execution.js View on Github external
function setupChildProcessIpcChannel() {
  if (process.env.NODE_CHANNEL_FD) {
    const assert = require('internal/assert');

    const fd = parseInt(process.env.NODE_CHANNEL_FD, 10);
    assert(fd >= 0);

    // Make sure it's not accidentally inherited by child processes.
    delete process.env.NODE_CHANNEL_FD;

    require('child_process')._forkChild(fd);
    assert(process.send);
  }
}
github pmq20 / node-packer / node / lib / internal / process.js View on Github external
// start parsing data from that stream.
  if (process.env.NODE_CHANNEL_FD) {
    const fd = parseInt(process.env.NODE_CHANNEL_FD, 10);
    assert(fd >= 0);

    // Make sure it's not accidentally inherited by child processes.
    delete process.env.NODE_CHANNEL_FD;

    const cp = require('child_process');

    // Load tcp_wrap to avoid situation where we might immediately receive
    // a message.
    // FIXME is this really necessary?
    process.binding('tcp_wrap');

    cp._forkChild(fd);
    assert(process.send);
  }
}

child_process

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

65 / 100
Full package analysis