[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why does </proc/self/environ not work in bash?
From: |
Chet Ramey |
Subject: |
Re: why does </proc/self/environ not work in bash? |
Date: |
Mon, 12 Feb 2024 10:13:53 -0500 |
User-agent: |
Mozilla Thunderbird |
On 2/10/24 11:00 PM, Christoph Anton Mitterer wrote:
Hey there.
I stumbled over something which I cannot really explain:
It depends on the behavior of the /proc driver.
Doing e.g.:
$ tr '\000' '\n' </proc/self/environ
in bash gives no output, while e.g. in dash
it gives the env vars, as I'd have expected it.
First question here is: whose environment should/would it return? The
shell's? tr's?
I'd assume the former, because the shell sets up the redirection
A system call tracer helps here. You'll find that the shell forks,
sets up the redirection by opening /proc/self/environ, then execs tr,
which reads the open file descriptor it inherits through execve. Does
the /proc driver invalidate the inherited file descriptor?
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
OpenPGP_signature.asc
Description: OpenPGP digital signature
Re: why does </proc/self/environ not work in bash?, Greg Wooledge, 2024/02/11
Re: why does </proc/self/environ not work in bash?,
Chet Ramey <=
- Re: why does </proc/self/environ not work in bash?, Zachary Santer, 2024/02/12
- Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/12
- Re: why does </proc/self/environ not work in bash?, Zachary Santer, 2024/02/12
- Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/13
- Re: why does </proc/self/environ not work in bash?, Zachary Santer, 2024/02/13
- Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/13
- Re: why does </proc/self/environ not work in bash?, Zachary Santer, 2024/02/13
- Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/13
- Re: why does </proc/self/environ not work in bash?, Zachary Santer, 2024/02/14
- Re: why does </proc/self/environ not work in bash?, Chet Ramey, 2024/02/14