From cfbbc947515148333c063b27af6bffac75e5c8e8 Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Fri, 7 Jul 2017 16:35:32 +0200 Subject: [PATCH] Assume the availability of POSIX signals --- configure.ac | 9 --------- src/ezstream.c | 32 +++++++------------------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/configure.ac b/configure.ac index fbf0ef9..7b4d06a 100644 --- a/configure.ac +++ b/configure.ac @@ -226,15 +226,6 @@ AC_REPLACE_FUNCS([ \ strtonum \ ]) -AC_CHECK_FUNCS([sigaction], [ - AC_DEFINE([HAVE_SIGNALS], [1], - [Define to 1 if we have BSD signals.]) - ], [], [ - #ifdef HAVE_SIGNAL_H - # include - #endif - ]) - AC_CHECK_FUNC([clock_gettime], [], [ AC_CHECK_LIB([rt], [clock_gettime], [ AX_UNIQVAR_PREPEND([EZ_LIBS], [-lrt]) diff --git a/src/ezstream.c b/src/ezstream.c index b2d5fde..9ac6932 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -21,9 +21,7 @@ #include "ezstream.h" -#ifdef HAVE_SIGNAL_H -# include -#endif +#include #include "cfg.h" #include "cmdline.h" @@ -44,7 +42,6 @@ playlist_t playlist; int playlistMode; unsigned int resource_errors; -#ifdef HAVE_SIGNALS const int ezstream_signals[] = { SIGTERM, SIGINT, SIGHUP, SIGUSR1, SIGUSR2 }; @@ -54,13 +51,6 @@ volatile sig_atomic_t rereadPlaylist_notify; volatile sig_atomic_t skipTrack; volatile sig_atomic_t queryMetadata; volatile sig_atomic_t quit; -#else -int rereadPlaylist; -int rereadPlaylist_notify; -int skipTrack; -int queryMetadata; -int quit; -#endif /* HAVE_SIGNALS */ typedef struct tag_ID3Tag { char tag[3]; @@ -72,6 +62,7 @@ typedef struct tag_ID3Tag { char genre; } ID3Tag; +void sig_handler(int); char * buildReencodeCommand(const char *, const char *, metadata_t); metadata_t getMetadata(const char *); FILE * openResource(stream_t, const char *, int *, metadata_t *, @@ -84,13 +75,6 @@ int streamFile(stream_t, const char *); int streamPlaylist(stream_t); int ez_shutdown(int); -#ifdef HAVE_SIGNALS -void sig_handler(int); - -# ifndef SIG_IGN -# define SIG_IGN (void (*)(int))1 -# endif /* !SIG_IGN */ - void sig_handler(int sig) { @@ -113,7 +97,6 @@ sig_handler(int sig) break; } } -#endif /* HAVE_SIGNALS */ char * buildReencodeCommand(const char *extension, const char *fileName, @@ -781,10 +764,8 @@ main(int argc, char *argv[]) stream_t stream; extern char *optarg; extern int optind; -#ifdef HAVE_SIGNALS struct sigaction act; unsigned int i; -#endif ret = 1; if (0 > cfg_init() || @@ -806,12 +787,11 @@ main(int argc, char *argv[]) if (0 > stream_setup(stream)) return (ez_shutdown(1)); -#ifdef HAVE_SIGNALS memset(&act, 0, sizeof(act)); act.sa_handler = sig_handler; -# ifdef SA_RESTART +#ifdef SA_RESTART act.sa_flags = SA_RESTART; -# endif +#endif for (i = 0; i < sizeof(ezstream_signals) / sizeof(int); i++) { if (sigaction(ezstream_signals[i], &act, NULL) == -1) { log_syserr(ERROR, errno, "sigaction"); @@ -822,12 +802,14 @@ main(int argc, char *argv[]) * Ignore SIGPIPE, which has been seen to give a long-running ezstream * process trouble. EOF and/or EPIPE are also easier to handle. */ +#ifndef SIG_IGN +# define SIG_IGN (void (*)(int))1 +#endif /* !SIG_IGN */ act.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &act, NULL) == -1) { log_syserr(ERROR, errno, "sigaction"); return (ez_shutdown(1)); } -#endif /* HAVE_SIGNALS */ if (0 > stream_connect(stream)) { log_error("initial server connection failed");