From ccef06106c0b5e60fcbb9a636fd784638e9fc902 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 15 Jun 2003 18:17:24 +0000 Subject: [PATCH] @@ -10,6 +10,8 @@ + * Use fcntl F_{GET,SET}FD with respect for as-yet-uninvented fd flags. + (small patch from Ben Harris.) --- debian/changelog | 2 ++ servexec.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5bf6e6a..248f460 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ userv (1.0.2) unstable; urgency=low * We do ship m4 and flex output now, so say so. * install-sh updated to that from autoconf 2.53. * Look for gmd5sum. (Thanks to Anton Altaparmakov for the report.) + * Use fcntl F_{GET,SET}FD with respect for as-yet-uninvented fd flags. + (small patch from Ben Harris.) Debian: * Priority changed to optional as per override file. diff --git a/servexec.c b/servexec.c index a71b64f..8c3494a 100644 --- a/servexec.c +++ b/servexec.c @@ -224,7 +224,7 @@ void execservice(const int synchsocket[], int clientfd) { "-", 0 }; - int fd, realfd, holdfd, newfd, r, envvarbufsize=0, targ, nargs, i, l; + int fd, realfd, holdfd, newfd, r, envvarbufsize=0, targ, nargs, i, l, fdflags; char *envvarbuf=0; const char **args, *const *cpp; char *const *pp; @@ -286,7 +286,8 @@ void execservice(const int synchsocket[], int clientfd) { } if (dup2(fdarray[fd].realfd,fd)<0) serv_syscallfail("dup2 set up fd"); if (close(fdarray[fd].realfd)) serv_syscallfail("close old fd"); - if (fcntl(fd,F_SETFD,0)<0) serv_syscallfail("set no-close-on-exec on fd"); + fdflags= fcntl(fd,F_GETFD); if (fdflags<0) serv_syscallfail("get fd flags"); + if (fcntl(fd,F_SETFD,fdflags&~FD_CLOEXEC)==-1) serv_syscallfail("set no-close-on-exec on fd"); fdarray[fd].realfd= fd; } -- 2.30.2