This command does not terminate
echo `bash -c 'tail -f /dev/null & echo hello world'`
despite the fact that
bash -c 'tail -f /dev/null & echo hello world'
correctly returns "hello world"
I am trying to background a command inside a bash script that is evaluated inside backticks. I actually need to run eval and not echo, for for this example I'm using echo. The script in question emulates an ssh-agent which outputs typically a number of export statements. However, inside the script I need to background a job.
I have tried to use disown
, nohup
or $()
instead of backticks. It seems that the backticks always wait for the termination of all child processes. Is there a way to circumvent this? I particularly would be interested in receiving the PID of the backgrounded command.