|Perl Monk, Perl Meditation|
I see the system-ed perl as an autonomous process (unknowing of its parent process)
You are also probably aware tha fork preserves open file descriptors. This is why to create a daemon, it is necessary to fork twice. You fork once, close the standard handles in the child; and then fork a second time. Only then does the second child become disassociated with the terminal and a true daemon.
To quote the above man page:By default, file descriptors remain open across an execve().
You can prove this to yourself. Run this one-liner (suitably adjusted):
And you'll see the output 123
Now try this modified version:
Where did the output disappear to?
So bang goes the autonomous process theory.
In both cases, we're printing out a string with one character at codepoint U+00FF.
No. The return value from pack 'B8', ... is not a character; nor a codepoint; and absolutely nothing to do with Unicode.
It is a byte! An 8-bit
No interpretation of the meaning (nor even signedness) is placed (nor could be) upon that value until you do something with it!
The second system-ed perl has its output set ...
You're right that the interpretation applied to the 8-bit value is not preserved across the fork/exec pair, but not because of your reasoning.
The important part is that the OS cannot preserve what it has no knowledge of. There is no concept of encoding attached to the file descriptors.
It is also likely, though I haven't confirmed this, that Perl reopens the standard handles when it starts.
The bottom line -- for this thread, rather than this subthread -- is that the OP must have omitted some details from his scenario.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.