]> sjero.net Git - wget/blobdiff - src/main.c
[svn] Expect existence of C89 functions, as well as of select and gettimeofday.
[wget] / src / main.c
index f9eabaf8bfc31e7aba6872147a93a5497199c17c..997a2de738f48d4c30941ab1e9b6c6f010ea2705 100644 (file)
@@ -35,14 +35,10 @@ so, delete this exception statement from your version.  */
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 #include <string.h>
-#ifdef HAVE_SIGNAL_H
-# include <signal.h>
-#endif
-#ifdef HAVE_NLS
-#ifdef HAVE_LOCALE_H
+#include <signal.h>
+#if defined(HAVE_NLS) && defined(HAVE_LOCALE_H)
 # include <locale.h>
-#endif /* HAVE_LOCALE_H */
-#endif /* HAVE_NLS */
+#endif
 #include <assert.h>
 #include <errno.h>
 
@@ -70,7 +66,7 @@ extern char *version_string;
 
 extern struct cookie_jar *wget_cookie_jar;
 
-static RETSIGTYPE redirect_output_signal (int);
+static void redirect_output_signal (int);
 
 const char *exec_name;
 \f
@@ -904,21 +900,25 @@ Can't timestamp and not clobber old files at the same time.\n"));
   ws_startup ();
 #endif
 
+#ifdef SIGHUP
   /* Setup the signal handler to redirect output when hangup is
      received.  */
-#ifdef HAVE_SIGNAL
   if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
     signal(SIGHUP, redirect_output_signal);
+#endif
   /* ...and do the same for SIGUSR1.  */
+#ifdef SIGUSR1
   signal (SIGUSR1, redirect_output_signal);
+#endif
+#ifdef SIGPIPE
   /* Writing to a closed socket normally signals SIGPIPE, and the
      process exits.  What we want is to ignore SIGPIPE and just check
      for the return value of write().  */
   signal (SIGPIPE, SIG_IGN);
+#endif
 #ifdef SIGWINCH
   signal (SIGWINCH, progress_handle_sigwinch);
 #endif
-#endif /* HAVE_SIGNAL */
 
   status = RETROK;             /* initialize it, just-in-case */
   /* Retrieve the URLs from argument list.  */
@@ -990,16 +990,12 @@ Can't timestamp and not clobber old files at the same time.\n"));
     return 1;
 }
 \f
-#ifdef HAVE_SIGNAL
+#if defined(SIGHUP) || defined(SIGUSR1)
 /* Hangup signal handler.  When wget receives SIGHUP or SIGUSR1, it
    will proceed operation as usual, trying to write into a log file.
-   If that is impossible, the output will be turned off.
-
-   #### It is unsafe to do call libc functions from a signal handler.
-   What we should do is, set a global variable, and have the code in
-   log.c pick it up.  */
+   If that is impossible, the output will be turned off.  */
 
-static RETSIGTYPE
+static void
 redirect_output_signal (int sig)
 {
   const char *signal_name = (sig == SIGHUP ? "SIGHUP" :
@@ -1009,4 +1005,4 @@ redirect_output_signal (int sig)
   progress_schedule_redirect ();
   signal (sig, redirect_output_signal);
 }
-#endif /* HAVE_SIGNAL */
+#endif