help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why does </proc/self/environ not work in bash?


From: Koichi Murase
Subject: Re: why does </proc/self/environ not work in bash?
Date: Sun, 11 Feb 2024 13:16:27 +0900

2024年2月11日(日) 13:01 Christoph Anton Mitterer <calestyo@scientia.org>:
> Which would be what I'd expect if one did e.g.
>   $ cat /proc/self/comm
> where the program get's the path as argument and opens it, but not
> when doing:
>   $ cat </proc/self/comm

I haven't checked how Bash actually implements it in the codebase, but
redirections can be performed in different places depending on the
implementation. One could open the file in the parent process and
perform fork&exec as a possible implementation, but as another
implementation, one can first perform the fork, perform the
redirection, and finally perform the exec. In that case, /proc/self
would reference cat or tr even when it is opened by a redirection.

--
Koichi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]