summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2018-02-25 12:50:20 -0500
committerJune McEnroe <programble@gmail.com>2018-02-25 12:50:20 -0500
commit622a1c15dd83b93b4c6cf0f133bd99b8151a7cae (patch)
tree6a6e9e1a8b12a2ebc210e451b9a42ace62cd0701 /bin
parentClean up klon (diff)
downloadsrc-622a1c15dd83b93b4c6cf0f133bd99b8151a7cae.tar.gz
src-622a1c15dd83b93b4c6cf0f133bd99b8151a7cae.zip
Tweak watch exit codes
Diffstat (limited to 'bin')
-rw-r--r--bin/watch.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/bin/watch.c b/bin/watch.c
index 2787a45a..5b13b7e3 100644
--- a/bin/watch.c
+++ b/bin/watch.c
@@ -26,7 +26,7 @@
 
 static void watch(int kq, char *path) {
     int fd = open(path, O_RDONLY);
-    if (fd < 0) err(EX_IOERR, "%s", path);
+    if (fd < 0) err(EX_NOINPUT, "%s", path);
 
     struct kevent event = {
         .ident = fd,
@@ -36,7 +36,7 @@ static void watch(int kq, char *path) {
         .udata = path,
     };
     int nevents = kevent(kq, &event, 1, NULL, 0, NULL);
-    if (nevents < 0) err(EX_IOERR, "kevent");
+    if (nevents < 0) err(EX_OSERR, "kevent");
 }
 
 static void exec(char *const argv[]) {
@@ -44,8 +44,8 @@ static void exec(char *const argv[]) {
     if (pid < 0) err(EX_OSERR, "fork");
 
     if (!pid) {
-        execvp(argv[0], argv);
-        err(EX_OSERR, "%s", argv[0]);
+        execvp(*argv, argv);
+        err(EX_NOINPUT, "%s", *argv);
     }
 
     int status;
@@ -67,27 +67,27 @@ int main(int argc, char *argv[]) {
     int kq = kqueue();
     if (kq < 0) err(EX_OSERR, "kqueue");
 
-    int index;
-    for (index = 1; index < argc - 1; ++index) {
-        if (argv[index][0] == '-') {
-            index++;
+    int i;
+    for (i = 1; i < argc - 1; ++i) {
+        if (argv[i][0] == '-') {
+            i++;
             break;
         }
-        watch(kq, argv[index]);
+        watch(kq, argv[i]);
     }
 
-    exec(&argv[index]);
+    exec(&argv[i]);
 
     for (;;) {
         struct kevent event;
         int nevents = kevent(kq, NULL, 0, &event, 1, NULL);
-        if (nevents < 0) err(EX_IOERR, "kevent");
+        if (nevents < 0) err(EX_OSERR, "kevent");
 
         if (event.fflags & NOTE_DELETE) {
             close(event.ident);
             watch(kq, event.udata);
         }
 
-        exec(&argv[index]);
+        exec(&argv[i]);
     }
 }
bc0dbca2bdd0506219bbfbfed4a9ede387850c&follow=1'>Add inflateBack.3June McEnroe 2018-11-12Add inflateBackInit.3June McEnroe 2018-11-11Add inflateGetHeader.3June McEnroe 2018-11-11Add inflateMark.3June McEnroe 2018-11-11Add inflatePrime.3June McEnroe 2018-11-11Add inflateReset.3June McEnroe 2018-11-11Add inflateCopy.3June McEnroe 2018-11-11Add inflateSync.3June McEnroe 2018-11-11Add inflateGetDictionary.3June McEnroe 2018-11-11Add inflateSetDictionary.3June McEnroe 2018-11-11Add inflateInit2.3June McEnroe