Close orig stdout, stderr, when logging to file
authorFilippos Giannakos <philipgian@grnet.gr>
Mon, 15 Apr 2013 08:31:53 +0000 (11:31 +0300)
committerFilippos Giannakos <philipgian@grnet.gr>
Mon, 15 Apr 2013 08:31:53 +0000 (11:31 +0300)
xseg/sys/user/_sysutil.h
xseg/sys/user/xseg_user.c

index 164eead..dbeb178 100644 (file)
@@ -48,8 +48,8 @@
 
 
 struct log_ctx {
-       int stdout_orig;
-       int stderr_orig;
+//     int stdout_orig;
+//     int stderr_orig;
        char filename[MAX_LOGFILE_LEN];
        volatile int logfile;
        char peer_name[MAX_PEER_NAME];
index 6f70228..fc27953 100644 (file)
@@ -184,7 +184,7 @@ int __init_logctx(struct log_ctx *lc, char *peer_name,
 
        /* set logfile to stderr by default */
        lc->logfile = STDERR_FILENO;
-
+#if 0
        /* duplicate stdout, stderr */
        fd = dup(STDOUT_FILENO);
        if (fd < 0){
@@ -197,10 +197,10 @@ int __init_logctx(struct log_ctx *lc, char *peer_name,
                return -1;
        }
        lc->stderr_orig = fd;
-
+#endif
        lc->log_level = log_level;
        if (!logfile || !logfile[0]) {
-               lc->logfile = lc->stderr_orig;
+//             lc->logfile = lc->stderr_orig;
                return 0;
        }
 
@@ -208,7 +208,7 @@ int __init_logctx(struct log_ctx *lc, char *peer_name,
        lc->filename[MAX_LOGFILE_LEN - 1] = 0;
        fd = open(lc->filename, O_WRONLY|O_CREAT|O_APPEND, S_IRUSR|S_IWUSR);
        if (fd < 1){
-               lc->logfile = lc->stderr_orig;
+//             lc->logfile = lc->stderr_orig;
                return -1;
        }
        lc->logfile = fd;