In the meantime, in case you're curious, here's a program that reproduces the issue. I've attached a statically-compiled version too that can be disassembled. Running it: $ gcc -static a.c && ./a.out waitpid returned -10, wstat=0 #include #include int main(int argc, char **argv) { int wstat = 0; pid_t child = waitpid(-1, &wstat, WNOHANG); printf("waitpid returned %d, wstat=%d\n", child, wstat); return 0; } On Tue, Jan 19, 2021 at 12:17 PM Rasmus Andersson wrote: > > On Tue, Jan 19, 2021 at 11:33 AM Markus Wichmann wrote: > > > > On Tue, Jan 19, 2021 at 10:18:04AM -0800, Rasmus Andersson wrote: > > > However the wait4 syscall[3] in Linux 5 returns other values, > > > specifically it returns errors as negative values. The error that > > > trips up programs like runit's runsv is ECHILD (-10) which wait4 > > > returns when there are no children (i.e. they have exited.) > > > > > > > Hmm... that is very weird. That should not happen. Because the > > syscall_cp macro already contains a call to __syscall_ret(), which does > > exactly what you propose. So that means, there is something else going > > on in your copy of the code. Did you change anything about the source > > code? Or can you disassemble the function to see what it does? > > > Strange! You are right of course; looking at src/internal/syscall.h I > indeed see that syscall_cp calls __syscall_ret(__syscall_cp(args)) > The musl I'm building with comes from https://musl.cc/#binaries which > is created from these scripts according to the author: > https://git.zv.io/xstatic/mcm It doesn't seem to apply any patches. > Anyhow, I'm currently building musl & gcc myself using > musl-cross-make. I will see how that pans out and report back. > Thank you for your quick response Markus!