[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] How to get stdin from the parent process?
From: |
Peng Yu |
Subject: |
Re: [Help-bash] How to get stdin from the parent process? |
Date: |
Thu, 22 Feb 2018 08:24:09 -0600 |
> you can save stdin in another fd that will be inherited, then redirect stdin
> explicitely :
>
> #!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
> exec 3<&0
> (
> while read -r i
> do
> echo "$i"
> done
> ) <&3 &
> wait
Thanks.
In this specific case, I can move "<&3" into "()"? In other words, are
the file handles shared by the parent and the child?
My test case indicates so. But I want to make sure.
exec 3<&0
(
while read -r i
do
echo "$i"
done <&3
) &
wait
--
Regards,
Peng