x_stdout et al: should they ever be closed?

Derrell Lipman derrell.lipman at unwireduniverse.com
Thu Oct 2 13:14:13 GMT 2008


I just fixed a bug reported for libsmbclient, which involved setup_logging()
closing a previous log file descriptor before opening a new one.  The
problem was that if logging was specified to be "interactive" (i.e. to use
stdout instead of syslog), then file descriptor 1 would get closed when
setup_logging() was re-called.  I fixed it locally in setup_logging(), but I
wonder if the more general fix is appropriate.  Here's a proposed patch.
The question is, there is ever a time that the standard three file
descriptors should get closed by x_close()?

Derrell

diff --git a/source/lib/debug.c b/source/lib/debug.c
index 2ded6bd..76ac167 100644
--- a/source/lib/debug.c
+++ b/source/lib/debug.c
@@ -567,7 +567,9 @@ void setup_logging(const char *pname, bool interactive)
     stdout_logging = False;
     if (dbf) {
         x_fflush(dbf);
-        (void) x_fclose(dbf);
+                if (dbf != x_stdout) {
+                        (void) x_fclose(dbf);
+                }
     }

     dbf = NULL;


More information about the samba-technical mailing list