develooper Front page | perl.perl5.porters | Postings from June 2004

Re: [perl #29883] Closing file seems to cause a seek operation

From:
Nick Ing-Simmons
Date:
June 1, 2004 09:20
Subject:
Re: [perl #29883] Closing file seems to cause a seek operation
Message ID:
20040601162017.7519.7@llama.elixent.com
Dave Mitchell <davem@iabyn.com> writes:
>On Fri, May 28, 2004 at 11:26:51AM +0200, LAUN Wolfgang wrote:
>> According to a colleague who has looked into this, it is not clear
>> whether it is in the standard io library or buried deep in fork
>> handling. It should be reported to Sun, and we'd like to cooperate on
>> this with you. 
>
>Judging by a truss on a Solaris machine, the child process (which still
>has the file open), does, just before exiting:
>
>9041:   llseek(3, 0xFFFFFFFFFFFFFFE4, SEEK_CUR)         = 10
>9041:   close(3)                                        = 0
>
>
>ie its diddling with the current tell position, which is shared between
>parent and child. This then confuses the parent. Why the first child is
>subtracting 28 from the position I do not know. Looks a bit like it's
>trying to undo the stuff read into the buffer but not yet read by the
>application.

I believe that is the intent, and it was added because in the system()
case it was expected that 
   system();
   while (<>)
    {
    }
carried on where child left off.

>
>Given that perl doesn't use the OS's stdio library, I'm not sure we can
>entirely rule Perl out of the equation yet. But I'm tired and am going to
>bed now....

I think we can rule perl in - but the reset file position stuff 
was copied from somesystems stdio behaviour.





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