]> granicus.if.org Git - apache/commitdiff
PR 55670
authorNick Kew <niq@apache.org>
Sat, 19 Oct 2013 11:01:11 +0000 (11:01 +0000)
committerNick Kew <niq@apache.org>
Sat, 19 Oct 2013 11:01:11 +0000 (11:01 +0000)
Don't risk failing silently at startup when running in a tty.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1533728 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/main.c

diff --git a/CHANGES b/CHANGES
index f1f8310c4a25b570f97cbd280b07ce8028eccb92..d77d03ef095f6582ab1821969c7326f0c44c2ab0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) core: ensure any abnormal exit is reported to stderr if it's a tty.
+     PR 55670 [Nick Kew]
+
   *) mod_proxy: Added support for unix domain sockets as the
      backend server endpoint [Jim Jagielski, Blaise Tarr
      <blaise tarr gmail com>]
index 28d1872055f96bb9559975a931a732fd7f51016c..ef17af67082a62420b7acccf08eca7e38ce71482 100644 (file)
 
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>
+#else
+/* Not sure what absence of unistd would signify for tty.  Treating it as a
+ * big NO is safe, as we then won't try to write to stderr that's not a tty.
+ */
+#define isatty(n) (0)
 #endif
 
 /* WARNING: Win32 binds http_main.c dynamically to the server. Please place
@@ -263,6 +268,10 @@ static void destroy_and_exit_process(process_rec *process,
     ap_main_state = AP_SQ_MS_EXITING;
     apr_pool_destroy(process->pool); /* and destroy all descendent pools */
     apr_terminate();
+    if ((process_exit_value != 0) && isatty(fileno(stderr))) {
+        const char *name = process->short_name ? process->short_name : "httpd";
+        fprintf(stderr, "%s: abnormal exit %d\n", name, process_exit_value);
+    }
     exit(process_exit_value);
 }