X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fproc.c;h=e062cd0b7c702494a3992e8bfe1beab2a348113a;hp=2a5eda8304ea1c462612329118dbd698b00148c6;hb=cc06e1ff89ae4b7ffc8d95a8ab1d9b6787a5d142;hpb=be6994aece929425a7ac6bbdc770477cc527f2e8 diff --git a/src/ngircd/proc.c b/src/ngircd/proc.c index 2a5eda83..e062cd0b 100644 --- a/src/ngircd/proc.c +++ b/src/ngircd/proc.c @@ -79,7 +79,6 @@ Proc_Fork(PROC_STAT *proc, int *pipefds, void (*cbfunc)(int, short), int timeout signal(SIGALRM, Proc_GenericSignalHandler); close(pipefds[0]); alarm(timeout); - Conn_CloseAllSockets(); return 0; } @@ -138,13 +137,14 @@ Proc_Read(PROC_STAT *proc, void *buffer, size_t buflen) return 0; Log(LOG_CRIT, "Can't read from child process %ld: %s", proc->pid, strerror(errno)); + Proc_Close(proc); bytes_read = 0; + } else if (bytes_read == 0) { + /* EOF: clean up */ + LogDebug("Child process %ld: EOF reached, closing pipe.", + proc->pid); + Proc_Close(proc); } -#if DEBUG - else if (bytes_read == 0) - LogDebug("Can't read from child process %ld: EOF", proc->pid); -#endif - Proc_InitStruct(proc); return (size_t)bytes_read; } @@ -154,7 +154,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); }