correct indirection of nil. (steve stallion) also, return exit-status 1 in case of wait failure, and document the conversion from wait message to unix wait status which wasn't otherwise instantly obvious. Reference: /n/atom/patch/applied2013/sshwait2 Date: Wed Oct 2 16:22:49 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/ssh2/sshsession.c Wed Oct 2 16:19:04 2013 +++ /sys/src/cmd/ssh2/sshsession.c Wed Oct 2 16:19:04 2013 @@ -415,16 +415,20 @@ while (1) { fprint(errfd, "waiting for child %d\n", cmdpid); w = wait(); - fprint(errfd, "child %d passed\n", w->pid); - if (w->pid == cmdpid || w->pid == -1) + if (w == nil || w->pid == cmdpid) break; free(w); } - if (w->pid == -1) + if (w == nil){ fprint(errfd, "wait failed: %r\n"); - else - fprint(reqfd, "exit-status %d", w->msg[0]); - free(w); + fprint(reqfd, "exit-status 1"); + } + else { + fprint(errfd, "child %d exit-status %d\n", w->pid, *w->msg); + /* empty msg ≡ exit(0); non-empty ≡ exit(1) */ + fprint(reqfd, "exit-status %d", *w->msg != 0); + free(w); + } if (slfd > 0) fprint(slfd, "closing ssh session for %s\n", uname); else