diff -ur apcupsd-3.5.8.src.orig/apcpipe.c apcupsd-3.5.8.src/apcpipe.c --- apcupsd-3.5.8.src.orig/apcpipe.c Wed Apr 7 18:23:55 1999 +++ apcupsd-3.5.8.src/apcpipe.c Wed Apr 7 18:30:56 1999 @@ -132,6 +132,15 @@ }; /*********************************************************************/ +void sig_fifo_alarm (int sig) +{ + close(client_fifo_fd); + close(server_fifo_fd); + unlink(PIPE_FIFO); + unlink(ACCESS_FIFO); +} + +/*********************************************************************/ int pipe_requests (UPSINFO *ups) { int renetfd; @@ -141,8 +150,14 @@ ups->remotedown = FALSE; + signal(SIGALRM, sig_fifo_alarm); + alarm(5); + if ((server_fifo_fd = open(ACCESS_FIFO, O_RDONLY)) == -1) return(0); + + alarm(0); + signal(SIGALRM, SIG_IGN); if (mkfifo(PIPE_FIFO, 0777) == -1) { close(server_fifo_fd); diff -ur apcupsd-3.5.8.src.orig/apcupsd.c apcupsd-3.5.8.src/apcupsd.c --- apcupsd-3.5.8.src.orig/apcupsd.c Wed Apr 7 18:23:55 1999 +++ apcupsd-3.5.8.src/apcupsd.c Wed Apr 7 18:30:56 1999 @@ -362,6 +362,16 @@ { int KILL = FALSE; +#ifndef NEW_THREADS + + /* + * Clobber these to prevent hangs. + */ + + unlink(PIPE_FIFO); + unlink(ACCESS_FIFO); +#endif /* NEW_THREADS */ + if ((getuid() != 0) && (geteuid() != 0)) { fprintf(stderr, "%s: needs superuser privileges.\n", argv[0]); exit(1); diff -ur apcupsd-3.5.8.src.orig/include/apc_extern.h apcupsd-3.5.8.src/include/apc_extern.h --- apcupsd-3.5.8.src.orig/include/apc_extern.h Wed Apr 7 18:23:55 1999 +++ apcupsd-3.5.8.src/include/apc_extern.h Wed Apr 7 18:30:56 1999 @@ -176,6 +176,7 @@ /* * In apcpipe.c */ +extern void sig_fifo_alarm (int sig); extern int pipe_requests (UPSINFO *ups); extern int pipe_reconfig (UPSINFO *ups, CONFIGINFO *config); extern int pipe_master_status (UPSINFO *ups);