[hackers] [sbase] Exit with proper error codes || sin

From: <git_AT_suckless.org>
Date: Sat, 04 Jan 2014 14:54:04 +0100

commit 7ec616e1e5040e7c4b8c1e6dae0fc656e744a90f
Author: sin <sin_AT_2f30.org>
Date: Sat Jan 4 13:51:13 2014 +0000

    Exit with proper error codes
    
    We still have a few error codes to do, namely when the process
    is killed or stopped by a signal or when one or more invocations
    of the command returned a nonzero exit status.

diff --git a/xargs.c b/xargs.c
index da505f9..b283b5e 100644
--- a/xargs.c
+++ b/xargs.c
_AT_@ -1,4 +1,5 @@
 /* See LICENSE file for copyright and license details. */
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
_AT_@ -19,7 +20,7 @@ static int parsequote(int);
 static void parseescape(void);
 static char *poparg(void);
 static void pusharg(char *);
-static int runcmd(void);
+static void runcmd(void);
 
 static char **cmd;
 static char *argb;
_AT_@ -85,11 +86,7 @@ main(int argc, char *argv[])
                         i++;
                 }
                 cmd[i] = NULL;
- if (i == 1 && rflag == 1)
- ;
- else
- if (runcmd() == -1)
- arg = NULL;
+ if (i == 1 && rflag == 1); else runcmd();
                 for (; i >= 0; i--)
                         free(cmd[i]);
         } while (arg);
_AT_@ -221,7 +218,7 @@ pusharg(char *arg)
                 deinputc(*p);
 }
 
-static int
+static void
 runcmd(void)
 {
         pid_t pid;
_AT_@ -233,9 +230,9 @@ runcmd(void)
         if (pid == 0) {
                 execvp(*cmd, cmd);
                 eprintf("execvp %s:", *cmd);
+ _exit(errno == ENOENT ? 127 : 126);
         }
         wait(&status);
         if (WIFEXITED(status) && WEXITSTATUS(status) == 255)
- return -1;
- return 0;
+ exit(124);
 }
Received on Sat Jan 04 2014 - 14:54:04 CET

This archive was generated by hypermail 2.3.0 : Sat Jan 04 2014 - 15:00:11 CET