exit adhocify if command is not found irrespective of -e
Tento commit je obsažen v:
rodič
2e77170115
revize
875c176cc1
21
adhocify.c
21
adhocify.c
@ -280,7 +280,8 @@ bool run_prog(const char *eventfile, uint32_t eventmask)
|
|||||||
|
|
||||||
execvp(prog, script_arguments);
|
execvp(prog, script_arguments);
|
||||||
logerror("Exec of %s failed: %s\n", prog, strerror(errno));
|
logerror("Exec of %s failed: %s\n", prog, strerror(errno));
|
||||||
return false;
|
int exitcode = (errno == ENOENT) ? 127 : EXIT_FAILURE;
|
||||||
|
exit(exitcode);
|
||||||
}
|
}
|
||||||
if(pid == -1)
|
if(pid == -1)
|
||||||
{
|
{
|
||||||
@ -337,7 +338,6 @@ void check_forkbomb(const char *path_logfile, const char *path_prog)
|
|||||||
{
|
{
|
||||||
if(lkp->isdir)
|
if(lkp->isdir)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *dir_lkpPath = lkp->path;
|
char *dir_lkpPath = lkp->path;
|
||||||
if( STREQ(dir_lkpPath, dir_log) || STREQ(dir_lkpPath, dir_prog) )
|
if( STREQ(dir_lkpPath, dir_log) || STREQ(dir_lkpPath, dir_prog) )
|
||||||
{
|
{
|
||||||
@ -642,13 +642,17 @@ void child_handler(int signum, siginfo_t *info, void *context)
|
|||||||
logerror("waitpid failed when handling child exit\n");
|
logerror("waitpid failed when handling child exit\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
if(exit_with_child)
|
|
||||||
{
|
|
||||||
int adhocify_exit_code = 0;
|
int adhocify_exit_code = 0;
|
||||||
if(WIFEXITED(status))
|
if(WIFEXITED(status))
|
||||||
{
|
{
|
||||||
adhocify_exit_code = WEXITSTATUS(status);
|
adhocify_exit_code = WEXITSTATUS(status);
|
||||||
if(awaited_child_exit_code > -1)
|
if(adhocify_exit_code == 127)
|
||||||
|
{
|
||||||
|
logwrite("command not found, exiting\n");
|
||||||
|
exit(adhocify_exit_code);
|
||||||
|
}
|
||||||
|
if(exit_with_child && awaited_child_exit_code > -1)
|
||||||
{
|
{
|
||||||
bool must_exit = adhocify_exit_code == awaited_child_exit_code;
|
bool must_exit = adhocify_exit_code == awaited_child_exit_code;
|
||||||
if(negate_child_exit_code)
|
if(negate_child_exit_code)
|
||||||
@ -660,18 +664,15 @@ void child_handler(int signum, siginfo_t *info, void *context)
|
|||||||
logwrite("child exited with specified exit code, exiting too\n");
|
logwrite("child exited with specified exit code, exiting too\n");
|
||||||
exit(adhocify_exit_code);
|
exit(adhocify_exit_code);
|
||||||
}
|
}
|
||||||
return; //not the exit code we wanted, keep running
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(WIFSIGNALED(status))
|
if(exit_with_child && WIFSIGNALED(status))
|
||||||
{
|
{
|
||||||
adhocify_exit_code = 128 + WTERMSIG(status); //copy bash's behaviour
|
adhocify_exit_code = 128 + WTERMSIG(status); //copy bash's behaviour
|
||||||
}
|
|
||||||
//TODO: coredump?
|
|
||||||
exit(adhocify_exit_code);
|
exit(adhocify_exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_signals()
|
void set_signals()
|
||||||
{
|
{
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
|
Načítá se…
Odkázat v novém úkolu
Zablokovat Uživatele