diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-08 14:49:00 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-09-08 14:49:00 +0200 |
commit | 2839760066e578e449ebc8b3d71297b9f79a8c99 (patch) | |
tree | 95cae2887eaa016a1d9e2205420342e881bbddb0 /sys/src/cmd/rc | |
parent | 217e8a06198cf6681fb0c38c26f34d96ae4302f6 (diff) |
rc: fix Xpipefd unbalancing the redir stack
Xpipefd wants the pipe descriptor to be closed in turfredir(), so
it pushes the redirection, but this breaks Xpopredir after normal
redirection. so we shuffle the Xpipefd redir to the bottom of the
stack.
Diffstat (limited to 'sys/src/cmd/rc')
-rw-r--r-- | sys/src/cmd/rc/exec.c | 15 | ||||
-rw-r--r-- | sys/src/cmd/rc/fns.h | 1 | ||||
-rw-r--r-- | sys/src/cmd/rc/havefork.c | 3 |
3 files changed, 18 insertions, 1 deletions
diff --git a/sys/src/cmd/rc/exec.c b/sys/src/cmd/rc/exec.c index 10cb76935..4400e45bc 100644 --- a/sys/src/cmd/rc/exec.c +++ b/sys/src/cmd/rc/exec.c @@ -123,6 +123,21 @@ pushredir(int type, int from, int to) runq->redir = rp; } +void +shuffleredir(void) +{ + redir **rr, *rp; + + rp = runq->redir; + if(rp==0) + return; + runq->redir = rp->next; + rp->next = runq->startredir; + for(rr = &runq->redir; *rr != rp->next; rr = &((*rr)->next)) + ; + *rr = rp; +} + var* newvar(char *name, var *next) { diff --git a/sys/src/cmd/rc/fns.h b/sys/src/cmd/rc/fns.h index 1afe9ce38..e06265f65 100644 --- a/sys/src/cmd/rc/fns.h +++ b/sys/src/cmd/rc/fns.h @@ -55,6 +55,7 @@ void readhere(void); word* searchpath(char*); void setstatus(char*); void setvar(char*, word*); +void shuffleredir(void); void skipnl(void); void start(code*, int, var*); int truestatus(void); diff --git a/sys/src/cmd/rc/havefork.c b/sys/src/cmd/rc/havefork.c index ad5a80298..86d6c91f6 100644 --- a/sys/src/cmd/rc/havefork.c +++ b/sys/src/cmd/rc/havefork.c @@ -185,7 +185,8 @@ Xpipefd(void) default: addwaitpid(pid); close(sidefd); - pushredir(ROPEN, mainfd, mainfd); /* isn't this a noop? */ + pushredir(ROPEN, mainfd, mainfd); + shuffleredir(); /* shuffle redir to bottom of stack for turfredir() */ strcpy(name, Fdprefix); inttoascii(name+strlen(name), mainfd); pushword(name); |