Skip to content

Commit

Permalink
don't return 0 on exec failure
Browse files Browse the repository at this point in the history
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: #271
  • Loading branch information
N-R-K committed Oct 20, 2023
1 parent 6c8d64f commit a6ae534
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/scrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,10 @@ 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)
exit(69 /* EX_UNAVAILABLE */ );
free(execStr);
}

Expand Down

0 comments on commit a6ae534

Please sign in to comment.