diff options
author | June McEnroe <june@causal.agency> | 2024-05-22 19:39:44 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2024-05-22 19:39:44 -0400 |
commit | d3b3c96385a9f456ac7a0e8f7eaa615d1dfc78d4 (patch) | |
tree | 920ef7c7a642d01d8063f234ef4c63d865ad9808 /sandman.m | |
parent | Pronouns (diff) | |
download | catgirl-d3b3c96385a9f456ac7a0e8f7eaa615d1dfc78d4.tar.gz catgirl-d3b3c96385a9f456ac7a0e8f7eaa615d1dfc78d4.zip |
Remove use of sysexits.h
Preserve exit status 69 (EX_UNAVAILABLE) for getting disconnected. Use 127 for failing to exec, like the shell.
Diffstat (limited to 'sandman.m')
-rw-r--r-- | sandman.m | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/sandman.m b/sandman.m index 2e5c4db..c9d0705 100644 --- a/sandman.m +++ b/sandman.m @@ -19,7 +19,6 @@ #import <signal.h> #import <stdio.h> #import <stdlib.h> -#import <sysexits.h> #import <unistd.h> typedef unsigned uint; @@ -27,17 +26,17 @@ typedef unsigned uint; static pid_t pid; static void spawn(char *argv[]) { pid = fork(); - if (pid < 0) err(EX_OSERR, "fork"); + if (pid < 0) err(1, "fork"); if (pid) return; execvp(argv[0], argv); - err(EX_CONFIG, "%s", argv[0]); + err(127, "%s", argv[0]); } static void handler(int signal) { (void)signal; int status; pid_t pid = wait(&status); - if (pid < 0) _exit(EX_OSERR); + if (pid < 0) _exit(1); _exit(status); } @@ -47,12 +46,12 @@ int main(int argc, char *argv[]) { for (int opt; 0 < (opt = getopt(argc, argv, "t:"));) { switch (opt) { break; case 't': delay = strtoul(optarg, NULL, 10); - break; default: return EX_USAGE; + break; default: return 1; } } argc -= optind; argv += optind; - if (!argc) errx(EX_USAGE, "command required"); + if (!argc) errx(1, "command required"); NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; NSNotificationCenter *notifCenter = [workspace notificationCenter]; @@ -64,7 +63,7 @@ int main(int argc, char *argv[]) { (void)notif; signal(SIGCHLD, SIG_IGN); int error = kill(pid, SIGHUP); - if (error) err(EX_UNAVAILABLE, "kill"); + if (error) err(1, "kill"); int status; wait(&status); }]; |