rc

[fork] interactive rc shell
Log | Files | Refs | README | LICENSE

commit 604e3fa3c170ab78dc15c6ffded55fbc6ed4a041
parent 0d95155a112f968589ec737e9248ed171a002f1c
Author: tjg <tjg>
Date:   Thu, 20 Jun 2002 15:29:07 +0000

Initial revision

Diffstat:
Amkstatval.c | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/mkstatval.c b/mkstatval.c @@ -0,0 +1,26 @@ +#include <stdio.h> +#include <sys/types.h> +#include <sys/wait.h> +#include <unistd.h> + +int main(void) { + int cstatus, pstatus; + pid_t pid; + + for (cstatus = 0; cstatus < 2; ++cstatus) { + switch (pid = fork()) { + case -1: + perror("fork"); + return 1; + case 0: + _exit(cstatus); + default: + if (wait(&pstatus) != pid) { + perror("wait"); + return 1; + } + printf("#define STATUS%d %d\n", cstatus, pstatus); + } + } + return 0; +}