[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: eval doesn't close file descriptor?
From: |
Pierre Gaston |
Subject: |
Re: eval doesn't close file descriptor? |
Date: |
Tue, 12 Feb 2013 18:40:20 +0200 |
On Tue, Feb 12, 2013 at 6:07 PM, Matei David <matei.david@gmail.com> wrote:
> Ok, but I see the same behaviour when eval runs in a subshell:
>
> $ bash -c 'llfd () { echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/
> >&2; }; x=3; eval "exec $x>/dev/null"; llfd; echo | eval "llfd $x>&-"'
> [same output, fd 10 open, pointing to /dev/null, even though it's a
> subshell]
>
eval runs in a subshell, but it's the same thing inside this subshell.
eg you could have: echo | { eval "llfd "$x>&-"; echo blah >&3; }
Bash could optimize this once it realizes there's only one command, but
it's probably not that simple to implement.
Try with a function that spawns a subshell eg:
llfd () ( echo "pid:$BASHPID" >&2; ls -l /proc/$BASHPID/fd/ >&2; )
or llfd () { bash -c 'ls -l /proc/$$/fd' ; }
- eval doesn't close file descriptor?, matei . david, 2013/02/12
- Re: eval doesn't close file descriptor?, Pierre Gaston, 2013/02/12
- Re: eval doesn't close file descriptor?, Matei David, 2013/02/12
- Re: eval doesn't close file descriptor?,
Pierre Gaston <=
- Re: eval doesn't close file descriptor?, Matei David, 2013/02/12
- Re: eval doesn't close file descriptor?, Chet Ramey, 2013/02/12
- Re: eval doesn't close file descriptor?, Matei David, 2013/02/12
- Re: eval doesn't close file descriptor?, Ken Irving, 2013/02/12
- Re: eval doesn't close file descriptor?, Chet Ramey, 2013/02/12
- Re: eval doesn't close file descriptor?, Chet Ramey, 2013/02/12
- Re: eval doesn't close file descriptor?, Matei David, 2013/02/13
- Re: eval doesn't close file descriptor?, Matei David, 2013/02/13
- Re: eval doesn't close file descriptor?, Chet Ramey, 2013/02/17