Here’s some discussion upstream about this, with a testcase
and indication it’s not, in fact, a glibc bug.
--- Begin Message ---
> According to the reporter, they get a working ksh93 if they disable 
> posix_spawn configure option so it may be a, very widespread, bug in GNU libc 
> (Linux/kFreeBSD/Hurd-only, I presume).

I can confirm that disabling `posix_spawn` causes this bug to go away. OpenSUSE 
disables it in their build of ksh with a patch titled 
[ksh-qemu.patch](https://build.opensuse.org/package/view_file/shells/ksh/ksh-qemu.patch?expand=1),
 which implies there is another bug related to `posix_spawn` that affects QEMU.

-- 
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/ksh93/ksh/issues/79#issuecomment-660367476

--- End Message ---
--- Begin Message ---
Minimal reproducer for regression test:
```sh
printf '%s\n' 1 2 3 | while read line; do ls /dev/null; done
```
Normal output:
```
/dev/null
/dev/null
/dev/null
```
Bug output:
```
/dev/null
ls: ls: cannot execute [Exec format error]
ls: ls: cannot execute [Exec format error]
```

-- 
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/ksh93/ksh/issues/79#issuecomment-660373049

--- End Message ---
--- Begin Message ---
On macOS, the compiler flags used by the Apple version (which I've incorporated 
into `src/cmd/INIT/cc.darwin`) disable `SHOPT_SPAWN`. I can confirm that, if I 
change that flag to `-DSHOPT_SPAWN=1`, delete `arch` and recompile from 
scratch, I can reproduce this bug on the Mac.

I can also reproduce this bug on FreeBSD, on which `SHOPT_SPAWN` is not 
disabled by default.

Neither of these two systems use GNU libc, so it seems likely that this is a 
bug in ksh and not in any C library. Does anyone here have an idea how to fix 
it?

Alternatively, I wonder if there would be any disadvantage to simply removing 
the use of `posix_spawn` altogether.

-- 
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
https://github.com/ksh93/ksh/issues/79#issuecomment-660371047

--- End Message ---

Reply via email to