X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fproc.c;h=4220f1ab16f9101550e40df8e351caa777545b21;hp=fd2df1d947c51a773a9447a04e159e4a15afd8a4;hb=259c314d142abd6f9295047c116235cfdd119563;hpb=69803d6ff1ac8deb95e023bda6ad2aef435dc69a diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index fd2df1d9..4220f1ab 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -16,7 +16,6 @@ * Process management */ -#include "imp.h" #include #include #include @@ -27,8 +26,6 @@ #include "log.h" #include "io.h" #include "conn.h" - -#include "exp.h" #include "sighandlers.h" #include "proc.h" @@ -50,7 +47,9 @@ GLOBAL pid_t Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout) { pid_t pid; +#ifndef HAVE_ARC4RANDOM unsigned int seed; +#endif assert(proc != NULL); assert(pipefds != NULL); @@ -62,7 +61,9 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout return -1; } +#ifndef HAVE_ARC4RANDOM seed = (unsigned int)rand(); +#endif pid = fork(); switch (pid) { case -1: @@ -73,13 +74,17 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout return -1; case 0: /* New child process: */ +#ifdef HAVE_ARC4RANDOM_STIR + arc4random_stir(); +#endif +#ifndef HAVE_ARC4RANDOM srand(seed ^ (unsigned int)time(NULL) ^ getpid()); +#endif Signals_Exit(); signal(SIGTERM, Proc_GenericSignalHandler); signal(SIGALRM, Proc_GenericSignalHandler); close(pipefds[0]); alarm(timeout); - Conn_CloseAllSockets(); return 0; } @@ -155,7 +160,10 @@ Proc_Read(PROC_STAT *proc, void *buffer, size_t buflen) GLOBAL void Proc_Close(PROC_STAT *proc) { - io_close(proc->pipe_fd); + /* Close socket, if it exists */ + if (proc->pipe_fd >= 0) + io_close(proc->pipe_fd); + Proc_InitStruct(proc); }