bash - Redirect stdin to stdout while waiting for background process -
i have following code:
cmd cmd_args & wait_pid=$! trap "kill -s sigterm $wait_pid" sigterm sigint sigkill wait $wait_pid with want able kill background process whenever tries kill script. however, still want stdin redirected background process, not happening.
i grab wait's stdin , redirect background process. that, i've tried:
wait $wait_pid 0>&1 1> named_pipe but without luck.
as mentioned, can't trap sigkill (or sigstop).
other that, try this:
#!/bin/bash cmd cmd_args <&0 & wait_pid=$! trap "kill -s sigterm $wait_pid" sigterm sigint wait $wait_pid the <&0 tell bash want cmd's stdin script's stdin.
slightly off topic, interesting method of dumping bytes running process' stdin send them directly it's /proc file descriptor, in:
echo "stuff send process" >/proc/$wait_pid/fd/0
Comments
Post a Comment