From 6b3805724dc80fa34c6ab4bb9c822386f866ca63 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Fri, 7 May 2021 14:43:19 +0100 Subject: [PATCH] Re-obtain PID when optimising ( simple_command & ) (re: af6a32d1) src/cmd/ksh93/sh/xec.c: sh_exec(): TCOM: - In the referenced commit I'd accidentally deleted this line: shgd->current_pid = getpid(); from the routine to optimise the ( simple_command & ) case. This resulted in the following regression test failure on ARM boxes: variables.sh[71]: Test 4: $RANDOM seed in ( simple_command & ) The cause was that the current PID shgd->current_pid, which is factored into the seed, was not updated before reseeding. Apparently the system clock on ARM systems is not fine-grained enough to compensate. --- src/cmd/ksh93/sh/xec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c index 124d8e54a..898f414c8 100644 --- a/src/cmd/ksh93/sh/xec.c +++ b/src/cmd/ksh93/sh/xec.c @@ -1991,6 +1991,7 @@ int sh_exec(register const Shnode_t *t, int flags) _sh_fork(shp,pid,0,0); if(pid==0) { + shgd->current_pid = getpid(); sh_reseed_rand((struct rand*)RANDNOD->nvfun); shgd->realsubshell++; sh_exec(t->par.partre,flags);