Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
node <> Perl communication over additional fds
import { spawn } from 'child_process';
import { Writable, Readable } from 'stream';
const child = spawn(
['-e', `
use IO::Handle;
my $in = IO::Handle->new_from_fd($ENV{JIPE_RHS_STDIN_FD}, 'r');
my $out = IO::Handle->new_from_fd($ENV{JIPE_RHS_STDOUT_FD}, 'w');
while (<$in>) {
print $out $_;
env: {
shell: false,
stdio: ['pipe', 'pipe', 'inherit', 'pipe', 'pipe']
const childStdout: Readable = child.stdio[3] as Readable;
const childStdin: Writable = child.stdio[4] as Writable;
childStdout.on('data', data => {
console.error('child said', data.toString());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.