summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2019-01-20 12:02:03 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2019-01-20 12:02:03 +0100
commit116b075371ec9a8af831e142f194a7a4a2fa738a (patch)
treeb9b914cf3296cce954bae76514a685d769fbd2df
parent83aa7ba70933335cd579b560a793b7741d5e3931 (diff)
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.
-rw-r--r--sys/src/cmd/rc/plan9.c9
1 files 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();
}