[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hpux-devtools
Subject:    RE: HPUX-DEVTOOLS: File Stream Buffer of fopen in HP-UX
From:       "BENNETT,ANDY (HP-Unitedkingdom,ex1)" <andy_bennett () hp ! com>
Date:       2003-02-26 10:28:49
[Download RAW message or body]

You are right about what is shared following a fork(). You are seeing the
problem because fclose() will try to fflush() the FILE buffer before calling
close() on the file descriptor and fflush() may modify the file descriptor's
file offset if there has been change in the FILE's buffer. So, yes, you may
see some change. This is not a good sign as it indicates the FILE
structure's buffer in the parent is probably going to be out of sync with
the file.

> -----Original Message-----
> From: CAO,THOMAS-DS (HP-China,ex2) [mailto:thomas-ds_cao@hp.com]
> Sent: 26 February 2003 02:02
> To: HPUX-DEV
> Subject: HPUX-DEVTOOLS: File Stream Buffer of fopen in HP-UX
> 
> 
> I think the file stream buffer is shared between HP-UX processes of
> parent/child after fork if the file is opened using fopen 
> before the fork
> operation. The current file position as reported by ftell in 
> parent seems be
> set at random places by the fclose of the child. I just want 
> to make sure if
> this is the true that the FILE structure can not be shared by multiple
> processes, but the parent and child will just share this FILE 
> stream after
> fork.
> 
> Thanks,
> Thomas
>  _________________________________________________________________
>  To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
>     with the message UNSUBSCRIBE hpux-devtools
>  _________________________________________________________________
> 
 _________________________________________________________________
 To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
    with the message UNSUBSCRIBE hpux-devtools
 _________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic