Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] Solaris-specific program flow corruption after subshell error exit

Op 26-02-17 om 21:29 schreef Bart Schaefer:
> In particular I'm guessing that the POSIX-compatible behavior referenced
> at the "fatal:" label in exec.c near line 4000 is leaving some kind of
> shared stdin state between the parent and the subshell, because "set"
> is a special builtin so will invoke the exit at that point.  Without
> actually running the code, I'd expect we're going through the _exit()
> branch rather than the exit() branch which under normal circumstances is
> deliberately to avoid having such shared state mess up the parent file
> descriptor positions, but maybe that's not sufficient.

I can't comment on that, but I did a little uninformed experimenting.

From line 4002:

    if (forked)

if I change the second "exit(1)" to "_exit(1)", the bug disappears and
the shell *appears* to act normally, at least with all the POSIX options
active. It passes the modernish test suite and runs all the example
programs without a hitch.

So that appears to suggest that the problem is something to do with
invoking exit() and not _exit() upon exiting a subshell on error. Could
it be that the 'forked' flag contains the wrong value?

- M.

Messages sorted by: Reverse Date, Date, Thread, Author