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 18, 2023
1 parent 6c8d64f commit 83177b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/scrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 83177b0

Please sign in to comment.