repeat to actual stderr output in log_system_error_and_exit()
authorAlexey Chernobaev <achernobaev@dev.rtsoft.ru>
Wed, 29 Aug 2018 17:27:22 +0000 (20:27 +0300)
committerAleksei Vereshchagin <avereschagin@dev.rtsoft.ru>
Mon, 3 Sep 2018 15:21:42 +0000 (18:21 +0300)
profctl.c

index 1d1951fed66b51e682931f698ec6900c0a9b6b21..7241ac468f76d83852df67e17def46ff1d2b2460 100644 (file)
--- a/profctl.c
+++ b/profctl.c
@@ -48,6 +48,8 @@ static char *oname = NULL;
 
 static int isPipeOwner = 0;
 
+static FILE *orig_stderr = NULL;
+
 static int controlPort = -1;
 static int dataPort = -1;
 static int statPort = -1;
@@ -117,6 +119,10 @@ static void log_system_error(const char *msg)
 static void log_system_error_and_exit(const char *msg)
 {
        log_prefixed_system_error("[FATAL] ", msg);
+       if ((orig_stderr != NULL) && (orig_stderr != stderr)) { // repeat to actual stderr
+               stderr = orig_stderr;
+               log_prefixed_system_error("[FATAL] ", msg);
+       }
        exit(1);
 }
 
@@ -658,6 +664,7 @@ int main(int argc, char **argv)
                log_system_error_and_exit("freopen");
        }
        setlinebuf(redir_stderr);
+       orig_stderr = stderr;
        stderr = redir_stderr;
 
        if (verbose) {