From 85bd72e348aa2bef9d6c98f5a2c5fa5b2b03c201 Mon Sep 17 00:00:00 2001 From: ian Date: Sat, 1 Nov 2003 00:18:38 +0000 Subject: [PATCH] @@ -3,6 +3,8 @@ their use of strtoul. (Thanks to report from Peter Benie.) + * Close unwanted pipes in client-side cat subprocesses, to avoid + wedging at termination. (Thanks to patchlet from Peter Benie.) --- client.c | 16 ++++++++++++++++ debian/changelog | 2 ++ 2 files changed, 18 insertions(+) diff --git a/client.c b/client.c index 9fb76df..0af49e8 100644 --- a/client.c +++ b/client.c @@ -1163,6 +1163,21 @@ static void prepare_asynchsignals(void) { if (alarm(timeout)<0) syscallerror("set up timeout alarm"); } + +static void cat_close_unwanted_pipes(void) { + int fd; + + for (fd=0; fd2) + if (close(fdsetup[fd].copyfd)) + if (errno != EBADF) + /* EBADF can be induced if cmd line specifies same fd twice */ + fsyscallerror("close real fd for %d",fd); + } +} + static void catdup(const char *which, int from, int to) { if (dup2(from,to)<0) { blocksignals(SIG_BLOCK); @@ -1205,6 +1220,7 @@ 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); + cat_close_unwanted_pipes(); execl("/bin/cat",catnamebuf,(char*)0); fprintf(stderr,"userv: %s: cannot exec `cat': %s\n",catnamebuf,strerror(errno)); exit(-1); diff --git a/debian/changelog b/debian/changelog index e7e6bf5..b9bd345 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ userv (1.0.1.99.2) unstable; urgency=low * Actually ship uservd(8) ! * Fix fd modifier, signal, and exit status parsing to be rigourous in their use of strtoul. (Thanks to report from Peter Benie.) + * Close unwanted pipes in client-side cat subprocesses, to avoid + wedging at termination. (Thanks to patchlet from Peter Benie.) -- -- 2.30.2