summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2020-05-30 02:03:18 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2020-05-30 02:03:18 +0200
commita48b462e4464c762fac0c8fa0af18d05db2a725f (patch)
tree1f47ba4565de52b326fc6a40407ee298b1ca5e48
parent0e97c8d1d7dd8dc2ba800656939106721b1d816f (diff)
downloadplan9front-a48b462e4464c762fac0c8fa0af18d05db2a725f.tar.xz
rc: avoid forking for final command that has variable assignments (to get $apid right)
basically, we want the following commands to print the same pid twice: rc -c 'cat /dev/pid &;echo $apid' vs: rc -c 'a=1 cat /dev/pid &;echo $apid' basically, Xsimple() calls exitnext() to determine if a simple command should be promoted to exec, by peeking ahead into the code and searching for Xexit instruction. Xexit might not follow immediately after the Xsimple instruction because of redirections, which exitnext() would skip. but it would not skip the Xunlocal instructions that where added by the variable assignment.
-rw-r--r--sys/src/cmd/rc/simple.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/src/cmd/rc/simple.c b/sys/src/cmd/rc/simple.c
index 982b73cda..8971f201f 100644
--- a/sys/src/cmd/rc/simple.c
+++ b/sys/src/cmd/rc/simple.c
@@ -12,7 +12,7 @@
int
exitnext(void){
union code *c=&runq->code[runq->pc];
- while(c->f==Xpopredir) c++;
+ while(c->f==Xpopredir || c->f==Xunlocal) c++;
return c->f==Xexit;
}