diff options
author | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2023-11-11 21:28:00 +0100 |
---|---|---|
committer | Tristan Riehs <tristan.riehs@bordeaux-inp.fr> | 2023-11-11 21:28:00 +0100 |
commit | 957af01fc24ef4fb2311431d0af9088575eba002 (patch) | |
tree | 2b0ea641ee29e78f9454ee93aa6e937f499bb97e | |
parent | 7a307a7ec28329776220e34843d05617934c4763 (diff) |
exit status defined as macros
-rw-r--r-- | rpt.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -15,6 +15,13 @@ /* Size of the buffer used to clone stdin. */ #define BUFSIZE 8000 +/* Exit status */ +#define EXIT_SUCCESS 0 +#define EXIT_INVALID_ARG 1 +#define EXIT_INVALID_COUNT 2 +#define EXIT_NO_COMMAND 3 +#define EXIT_OTHER 4 + /* Clone of stdin. Used to perform lseek(2) calls between each child process. */ FILE *stdin_clone = NULL; @@ -80,7 +87,7 @@ exec_child(char **argv) if (status < 0) { perror("lseek"); - exit(4); + exit(EXIT_OTHER); } } @@ -89,7 +96,7 @@ exec_child(char **argv) if (status < 0) { perror("dup2"); - exit(4); + exit(EXIT_OTHER); } status = execvp(argv[0], argv); @@ -97,10 +104,10 @@ exec_child(char **argv) if (status < 0) { perror("execvp"); - exit(4); + exit(EXIT_OTHER); } - exit(4); + exit(EXIT_OTHER); } void @@ -121,7 +128,7 @@ invoke_cmd(char **argv, void (*handle_error_f)(int status)) if (pid < 0) { perror("fork"); - exit(4); + exit(EXIT_OTHER); } if (pid == 0) @@ -150,7 +157,7 @@ copy_stdin() if (!stdin_clone) { perror("tmpfile"); - exit(1); + exit(EXIT_OTHER); } clone_fd = fileno(stdin_clone); @@ -165,7 +172,7 @@ copy_stdin() { fclose(stdin_clone); perror("read/write"); - exit(1); + exit(EXIT_OTHER); } } |