develooper Front page | perl.perl5.porters | Postings from December 2017

Re: [perl #127794] Strange behavior when forking in BEGIN

Thread Previous | Thread Next
From:
Zefram
Date:
December 19, 2017 01:19
Subject:
Re: [perl #127794] Strange behavior when forking in BEGIN
Message ID:
20171219011944.GS25404@fysh.org
Chad Granum wrote:
>That said, I would greatly prefer some kind of fix, though I understand
>that is probably not gonna happen.

Indeed.  A proper fix would amount to the child process getting a clone
of the open file description for the source file, as opposed to a clone
of the file descriptor referring to the same open file description.  It's
difficult to draw the line regarding which open file descriptions should
be cloned: things opened by the program might want the same treatment
as source, but many things want the default sharing behaviour.  But that
doesn't matter, because there's no way to clone open file descriptions.

Failing that, the next best thing would be to detect when a conflict
occurs.  You'd want to detect at read time that something else has
performed a read on the same open file description since the last read
you know about.  But that's also impossible.  For regular files you
could look at the file position, but that's subject to race condition,
and it doesn't apply at all to pipes.

So no fix is going to happen.

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About