Bash: Forward keyboard input to background program?

98 views Asked by At

I have a bash script where I spawn a program in a subshell and wait for it to finish:

#!/usr/bin/env bash

set -m
(
  theprogram & echo $! > "${PROGRAM_PID}"
)
set +m

tail --pid "$(cat "${PROGRAM_PID}")" --follow /dev/null & wait $!

The problem is that when the users presses any keys, they are not received by that program. I suppose this is caused by the fact that its running in a different process.

So is there any way to redirect all keyboard input to this PID?

0

There are 0 answers