Skip to content

Instantly share code, notes, and snippets.

@macedd
Created February 1, 2016 12:27
Show Gist options
  • Save macedd/9801561a5b18911bf6ff to your computer and use it in GitHub Desktop.
Save macedd/9801561a5b18911bf6ff to your computer and use it in GitHub Desktop.
Write to STDIN of running Process
## 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