From: ian Date: Fri, 12 Nov 2004 00:53:21 +0000 (+0000) Subject: fix (we hope) fd-handling hanging bug reported by Simon Tatham X-Git-Tag: debian_version_1_0_4~7 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=userv.git;a=commitdiff_plain;h=150ac98f750353e2631d48eba47476b81ba1a3fa fix (we hope) fd-handling hanging bug reported by Simon Tatham --- diff --git a/client.c b/client.c index ab3ae6f..c5fbcd5 100644 --- a/client.c +++ b/client.c @@ -132,7 +132,7 @@ static const char *loginname; static char *cwdbuf; static size_t cwdbufsize; static char *ovbuf; -static int ovused, systemerror; +static int ovused, systemerror, socketfd; static void blocksignals(int how) { sigset_t set; @@ -1220,6 +1220,8 @@ static void connect_pipes(void) { reading= fdsetup[fd].mods & fdm_read; catdup(catnamebuf, fdsetup[fd].copyfd, reading ? 0 : 1); catdup(catnamebuf, fdsetup[fd].pipefd, reading ? 1 : 0); + if (close(socketfd)) + fsyscallerror("%s: close client socket for for cat",catnamebuf); close_unwanted_pipes(); execl("/bin/cat",catnamebuf,(char*)0); fprintf(stderr,"userv: %s: cannot exec `cat': %s\n",catnamebuf,strerror(errno)); @@ -1326,7 +1328,7 @@ static void NONRETURNING process_exitstatus(int status) { } int main(int argc, char *const *argv) { - int status, socketfd; + int status; #ifdef NDEBUG # error Do not disable assertions in this security-critical code ! diff --git a/debian/changelog b/debian/changelog index 3a62245..8660c2f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,9 @@ userv (1.0.3.99-0.0.1) unstable; urgency=low + Bugfixes: + * Close client socket fd in spawned cats (avoids some service-side hangs + when client terminates). Thanks to report from Simon Tatham. + Minor portability fixes: * Missing #include and } Thanks to report * getgroups returns int, not gid_t (!). } from Peter Benie.