From 116b075371ec9a8af831e142f194a7a4a2fa738a Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 20 Jan 2019 12:02:03 +0100 Subject: [PATCH] rc: clear out redirections on "rfork F" (RFCFDG) rfork F closes all file descriptors, so we have to invalidate the redirections as they are now refering to closed files. not doing so causes the wrong file descriptors being closed later on as the fd numbers get reused. --- sys/src/cmd/rc/plan9.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/src/cmd/rc/plan9.c b/sys/src/cmd/rc/plan9.c index 187b6a74b..fd12e666c 100644 --- a/sys/src/cmd/rc/plan9.c +++ b/sys/src/cmd/rc/plan9.c @@ -93,9 +93,14 @@ execnewpgrp(void) if(rfork(arg)==-1){ pfmt(err, "rc: %s failed\n", runq->argv->words->word); setstatus("rfork failed"); - } - else + } else { + if(arg & RFCFDG){ + struct redir *rp; + for(rp = runq->redir; rp; rp = rp->next) + rp->type = 0; + } setstatus(""); + } poplist(); }