Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Setting $0 clears /proc/PID/environ too

by jcb (Curate)
on Jan 16, 2020 at 23:10 UTC ( #11111500=note: print w/replies, xml ) Need Help??


in reply to Setting $0 clears /proc/PID/environ too

The problem is that the process name and /proc/PID/environ are actually windows into the address space of the process. The pointers that determine these windows are in the kernel and the program cannot update them, but you can change the data stored in the region they point to.

Does changing $0 destroy %ENV or does perl copy the environment out of the way before reusing the original environment block?

Replies are listed 'Best First'.
Re^2: Setting $0 clears /proc/PID/environ too
by kikuchiyo (Pilgrim) on Jan 17, 2020 at 09:39 UTC

    Does changing $0 destroy %ENV or does perl copy the environment out of the way before reusing the original environment block?

    No, that happens very early, so even BEGIN blocks have %ENV correctly filled, and in any case later changes to %ENV are not reflected in /proc/PID/environ. That file is more like a historical record of what the environment was when the process started, and as such, it has potential (if marginal) uses, and that's why this bothers me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11111500]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (8)
As of 2020-04-01 09:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (186 votes). Check out past polls.

    Notices?