On 2016-04-16, Geoff Wozniak <ge...@wozniak.ca> wrote:

>   # zsh -c 'x=$(false); echo $?'
>   0

I can reproduce this.

> I've done this a few times and every time it's the same: on my 
> Thinkpad X200 the test produces '0' whereas any other machine I 
> install 5.9 on it produces '1'.

Very odd.  What I'm seeing here (with ktrace) should not differ
between OpenBSD installs.

The $(...) part is executed in a child process.  After the parent
reads an EOF from the pipe to the child, it does kill(child, 0).
And that's where things diverge:

* On OpenBSD, the kill() returns -1, errno ESRCH.  The parent
  proceeds to print the exit code 0, and only afterwards(!) fetches
  the return status of the child with wait4().

* On FreeBSD or Linux, the kill() returns 0.  The parent proceeds
  to fetch the return status of the child with wait4() and later
  prints the exit code 1.

Apparently zsh expects kill(zombie, 0) to succeed, but this fails
on OpenBSD.

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to