[PVFS-developers] Minor pvfs-1.6.3 pre1 patch (don't close
stdout in do_restart)
Rob Ross
rross at mcs.anl.gov
Mon May 3 12:28:24 EDT 2004
Good catch. Thanks.
On Mon, 3 May 2004, White Stuart - stwhit wrote:
> In the iod during startup, the code opens the logfile, and then calls dup2()
> on stdout and stderr, so that anything printed to stdout or stderr will get
> printed to the log file:
>
> if ((fd = open(logfile, logflags, 0700)) == -1) return -1;
> #endif
> fchmod(fd, 0755);
> dup2(fd, 2);
> dup2(fd, 1);
>
> Later, in do_restart(), which gets called when the manager gets bounced, the
> IOD closes all open file descriptors, except for the "accept" socket and
> stderr. It closes stdout.
>
> for (i=0; i < sysconf(_SC_OPEN_MAX); i++) {
> if (i != acc && i != 2) close(i);
> }
>
> So, stdout (fd 1) will get reused later when opening local data files. If a
> developer puts some debug code into the IOD which calls printf(), it works
> properly until the manager gets bounced, at which point the printf's start
> getting printed to one of the data files! You can imagine my surprise when
> my data files started getting corrupted by my debug printf's! :-)
>
> I have attached a patch that simply adds file descriptor 1 to the list of
> "special" file descriptors that do not get closed in do_restart().
>
> Thanks!
>
> Stuart White
>
>
>
> **********************************************************************
> The information contained in this communication is
> confidential, is intended only for the use of the recipient
> named above, and may be legally privileged.
> If the reader of this message is not the intended
> recipient, you are hereby notified that any dissemination,
> distribution, or copying of this communication is strictly
> prohibited.
> If you have received this communication in error,
> please re-send this communication to the sender and
> delete the original message or any copy of it from your
> computer system. Thank You.
>
>
More information about the PVFS-developers
mailing list