1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Switch from using signal() to sigaction() and friends, so that SA_RESTART can

be used. This is required for Solaris and possibly others, where signal handlers
have to be reinstalled after having caught one signal via signal(). Also prevent
Ezstream from being killed by a handled signal in streamFile(), where they
can interrupt fread()'s system calls. This improves matters, but isn't perfect,
yet. A SIGHUP signal can still cause skipping to the next track, which should
be triggered only by SIGUSR1.


git-svn-id: https://svn.xiph.org/trunk/ezstream@12563 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
moritz 2007-02-25 16:00:41 +00:00
parent 733c989d1b
commit ea8d29f742

View File

@ -58,6 +58,7 @@
# include "strlfctns.h"
#endif
#include "configfile.h"
#include "ezsignals.h"
#include "playlist.h"
#include "util.h"
@ -95,6 +96,8 @@ playlist_t *playlist = NULL;
int playlistMode = 0;
#ifdef HAVE_SIGNALS
const int ezstream_signals[] = { SIGHUP, SIGUSR1 };
volatile sig_atomic_t rereadPlaylist = 0;
volatile sig_atomic_t rereadPlaylist_notify = 0;
volatile sig_atomic_t skipTrack = 0;
@ -664,10 +667,14 @@ streamFile(shout_t *shout, const char *fileName)
break;
}
}
if (ferror(filepstream))
if (ferror(filepstream)) {
if (errno == EINTR) {
clearerr(filepstream);
retval = 1;
} else
printf("%s: streamFile(): Error while reading '%s': %s\n",
__progname, fileName, strerror(errno));
else
} else
retval = 1;
if (popenFlag)
@ -769,6 +776,9 @@ main(int argc, char *argv[])
shout_t *shout;
extern char *optarg;
extern int optind;
#ifdef HAVE_SIGNALS
struct sigaction act;
#endif
__progname = getProgname(argv[0]);
pezConfig = getEZConfig();
@ -994,8 +1004,12 @@ main(int argc, char *argv[])
}
#ifdef HAVE_SIGNALS
signal(SIGHUP, sig_handler);
signal(SIGUSR1, sig_handler);
memset(&act, 0, sizeof(act));
act.sa_handler = sig_handler;
# ifdef SA_RESTART
act.sa_flags = SA_RESTART;
# endif
SIGS_INSTALL(ezstream_signals, &act);
#endif /* HAVE_SIGNALS */
if (qFlag) {