💾 Archived View for thrig.me › tech › status-word.c captured on 2023-05-24 at 19:08:10.
⬅️ Previous capture (2023-04-26)
-=-=-=-=-=-=-
// status-word - show the exit status word from a program #include <sys/wait.h> #include <err.h> #include <stdio.h> #include <unistd.h> int main(void) { int status; pid_t pid = fork(); if (pid < 0) err(1, "fork failed"); if (pid) { wait(&status); printf("%d %d\n", status, status >> 8); } else { execlp("false", "false", (char *) 0); err(1, "execl failed"); } return 0; }