chiark / gitweb /
fix (we hope) fd-handling hanging bug reported by Simon Tatham
authorian <ian>
Fri, 12 Nov 2004 00:53:21 +0000 (00:53 +0000)
committerian <ian>
Fri, 12 Nov 2004 00:53:21 +0000 (00:53 +0000)
client.c
debian/changelog

index ab3ae6f0fb1e33fd16c8b6bba4ae1285f257229e..c5fbcd5a356dffaa61d3178932035dad1070a1a4 100644 (file)
--- 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 !
index 3a62245c6098a48a090168a845d68526283a8e7d..8660c2f047bada6a7d2cbd63f1d83afbd344d205 100644 (file)
@@ -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 <string.h> and <stdlib.h>  } Thanks to report
   * getgroups returns int, not gid_t (!).       }  from Peter Benie.