]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
treat exit 127 ass error
authorBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 28 Mar 2026 20:46:55 +0000 (21:46 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 28 Mar 2026 20:46:55 +0000 (21:46 +0100)
posix_spawnp(3) may report exec() failures via the
child's exit status (127) instead of the return value

src/utils.c

index ad22890d97d25c1d31b04c4f79280fd8fc7c9b88..38dd2e07d8cb30decdacaac08e280cbfdc0b555f 100644 (file)
@@ -198,6 +198,13 @@ exec_and_wait(const char *arg, ...)
        if (!WIFEXITED(pstat))
                return (-1);
 
+       /*
+        * posix_spawnp(3) may report exec() failures via the child's exit
+        * status (127) instead of the return value.
+        */
+       if (WEXITSTATUS(pstat) == 127)
+               return (-1);
+
        return (WEXITSTATUS(pstat));
 }