fix reintroduction of errno clobbering by atfork handlers
authorRich Felker <dalias@aerifal.cx>
Mon, 26 Oct 2020 22:06:18 +0000 (18:06 -0400)
committerRich Felker <dalias@aerifal.cx>
Mon, 26 Oct 2020 22:12:25 +0000 (18:12 -0400)
commit3437e478ba932edbab18a90638c20be1f0141156
tree8da34b267c3980cd633be6387b7dc1a2ec73f4f3
parent2d0bbe6c788938d1332609c014eeebc1dff966ac
fix reintroduction of errno clobbering by atfork handlers

commit bd153422f28634bb6e53f13f80beb8289d405267 reintroduced the bug
fixed in c21051e90cd27a0b26be0ac66950b7396a156ba1 by refactoring the
__syscall_ret into _Fork where it once again runs before the atfork
handlers are called. since _Fork is a public interface that sets
errno, this can't be fixed the way it was fixed last time without
making new internal interfaces. instead, just save errno, and restore
it only on error to ensure that a value of 0 is never restored.
src/process/fork.c