X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=process.c;fp=process.c;h=1d5963d937b7955583316dc2b374d76b36d55917;hb=7d720638764f8a58d122e5ee1c9e5cbb1497d987;hp=c4a4809ed419774707be172ef2023b03ad8bf14d;hpb=ccef06106c0b5e60fcbb9a636fd784638e9fc902;p=userv.git diff --git a/process.c b/process.c index c4a4809..1d5963d 100644 --- a/process.c +++ b/process.c @@ -443,6 +443,8 @@ static void receive_request(void) { assert(fdarray[fd].iswrite == -1); fdarray[fd].iswrite= (i>=request_mbuf.nreadfds); } + /* fdarray[].iswrite now set; rest is still blank + * (ie want reject read, no realfd holdfd). */ assert(request_mbuf.nargs <= MAX_ARGSDEFVAR); argarray= xmalloc(sizeof(char*)*(request_mbuf.nargs)); @@ -482,6 +484,14 @@ static void establish_pipes(void) { if (unlink(pipepathbuf)) syscallerror("unlink pipe"); if (close(tempfd)) syscallerror("close prelim fd onto pipe"); } + /* Now fdarray[].realfd is pipe end for service in case service + * wants it. If it's an input pipe, then .holdfd is the other + * (writing) end of the pipe - we keep it around so that the service + * doesn't get an apparently clean EOF if the caller disappears (eg + * due to a file read error) or the like (ie so that on disconnect + * we can guarantee to send the service SIGHUP before it gets EOF on + * the input fd). Otherwise, .holdfd=-1. + */ } static void groupnames(int ngids, gid_t *gids, const char ***names_r) { @@ -645,7 +655,6 @@ static void check_fds(void) { case tokv_word_requirefd: if (fdarray[fd].realfd == -1) failure("file descriptor %d required but not provided",fd); - assert(fdarray[fd].holdfd == -1); /* fall through */ case tokv_word_allowfd: if (fdarray[fd].realfd == -1) { @@ -662,6 +671,10 @@ static void check_fds(void) { } } } + /* Now fdarray[].realfd is exactly what service wants: pipe end or + * /dev/null or -1. If .realfd is not -1 then .holdfd may be the fd + * for the writing end of the corresponding pipe. + */ } static void send_progress_ok(void) {