From 83177b08b0fed4e32559c58cd7246e86e9d426ef Mon Sep 17 00:00:00 2001 From: NRK Date: Sun, 24 Sep 2023 23:15:17 +0600 Subject: [PATCH] don't return 0 on exec failure additionally return EX_UNAVAILABLE [0] if the child terminated abnormally or returned non-zero. [0]: https://man.freebsd.org/cgi/man.cgi?sektion=3&query=sysexits Closes: https://github.com/resurrecting-open-source-projects/scrot/issues/271 --- src/scrot.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/scrot.c b/src/scrot.c index 366654e..3b9b5c4 100644 --- a/src/scrot.c +++ b/src/scrot.c @@ -633,11 +633,13 @@ static void scrotExecApp(Imlib_Image image, struct tm *tm, char *filenameIM, { char *execStr = imPrintf(opt.exec, tm, filenameIM, filenameThumb, image); int ret = system(execStr); - if (ret == -1) - warn("The child process could not be created"); - else if (WIFEXITED(ret) && WEXITSTATUS(ret) == 127) - warnx("scrot could not execute the command: %s", execStr); + err(EXIT_FAILURE, "The child process could not be created"); + else if ((WIFEXITED(ret) && WEXITSTATUS(ret) != 0) + || (WIFSIGNALED(ret) && WTERMSIG(ret) != 0)) + { + exit(69 /* EX_UNAVAILABLE */ ); + } free(execStr); }