shithub: riscv

Download patch

ref: 96210d79b29eb31c6958c7aada57f39dc7f6cdcf
parent: 178bc8548acd64bc49f57c6b62de2daeb26cf046
parent: 2839760066e578e449ebc8b3d71297b9f79a8c99
author: cinap_lenrek <[email protected]>
date: Sat Sep 8 10:50:41 EDT 2018

merge

--- a/sys/src/cmd/rc/exec.c
+++ b/sys/src/cmd/rc/exec.c
@@ -123,6 +123,21 @@
 	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)
 {
--- a/sys/src/cmd/rc/fns.h
+++ b/sys/src/cmd/rc/fns.h
@@ -55,6 +55,7 @@
 word*	searchpath(char*);
 void	setstatus(char*);
 void	setvar(char*, word*);
+void	shuffleredir(void);
 void	skipnl(void);
 void	start(code*, int, var*);
 int	truestatus(void);
--- a/sys/src/cmd/rc/havefork.c
+++ b/sys/src/cmd/rc/havefork.c
@@ -185,7 +185,8 @@
 	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);