-
-
Save Happy-Ferret/34ad7f2ccc15696d80d6adf7d76f8e60 to your computer and use it in GitHub Desktop.
Write to STDIN of running Process
http://stackoverflow.com/questions/15624641/spawn-node-child-process-with-named-pipe-as-stdin
var spawn = require('child_process').spawn;
var fd_stdin = fs.openSync('lk.log', 'r');
spawn('node', ['monitor.js'], {
stdio: [fd_stdin, 1, 2];
});
http://stackoverflow.com/questions/33613341/how-to-send-broadcast-messages-with-named-pipe-using-c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Alternative 1: write to file descriptor (not usable) | |
input='testing' | |
pid=1212 | |
echo $input > /proc/$pid/fd/0 | |
## Alternative 2: Pipe fifo to the app | |
fifo_file=/tmp/fifo | |
mkfifo $fifo_file; cat > $fifo_file &; echo $! > {$fifo_file}.pid | |
(cat $fifo_file | myapp) | |
echo "testing" > $fifo_file | |
kill -9 `cat $fifo_file.pid` && rm $fifo_file* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment