mirror of
https://github.com/sudo-project/sudo.git
synced 2025-09-02 15:25:58 +00:00
Use pid_t not int and check the return value of kill()
This commit is contained in:
14
src/exec.c
14
src/exec.c
@@ -109,7 +109,7 @@ static int fork_cmnd(struct command_details *details, char *argv[],
|
|||||||
{
|
{
|
||||||
struct command_status cstat;
|
struct command_status cstat;
|
||||||
sigaction_t sa;
|
sigaction_t sa;
|
||||||
int pid;
|
pid_t child;
|
||||||
|
|
||||||
zero_bytes(&sa, sizeof(sa));
|
zero_bytes(&sa, sizeof(sa));
|
||||||
sigemptyset(&sa.sa_mask);
|
sigemptyset(&sa.sa_mask);
|
||||||
@@ -117,8 +117,8 @@ static int fork_cmnd(struct command_details *details, char *argv[],
|
|||||||
sa.sa_handler = handler;
|
sa.sa_handler = handler;
|
||||||
sigaction(SIGCONT, &sa, NULL);
|
sigaction(SIGCONT, &sa, NULL);
|
||||||
|
|
||||||
pid = fork();
|
child = fork();
|
||||||
switch (pid) {
|
switch (child) {
|
||||||
case -1:
|
case -1:
|
||||||
error(1, "fork");
|
error(1, "fork");
|
||||||
break;
|
break;
|
||||||
@@ -145,7 +145,7 @@ static int fork_cmnd(struct command_details *details, char *argv[],
|
|||||||
send(sv[1], &cstat, sizeof(cstat), 0);
|
send(sv[1], &cstat, sizeof(cstat), 0);
|
||||||
_exit(1);
|
_exit(1);
|
||||||
}
|
}
|
||||||
return pid;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct signal_state {
|
static struct signal_state {
|
||||||
@@ -437,7 +437,8 @@ handle_signals(int fd, pid_t child, int log_io, struct command_status *cstat)
|
|||||||
if (!log_io) {
|
if (!log_io) {
|
||||||
if (WIFSTOPPED(status)) {
|
if (WIFSTOPPED(status)) {
|
||||||
/* Child may not have privs to suspend us itself. */
|
/* Child may not have privs to suspend us itself. */
|
||||||
kill(getpid(), WSTOPSIG(status));
|
if (kill(getpid(), WSTOPSIG(status)) != 0)
|
||||||
|
warning("kill(%d, %d)", getpid(), WSTOPSIG(status));
|
||||||
} else {
|
} else {
|
||||||
/* Child has exited, we are done. */
|
/* Child has exited, we are done. */
|
||||||
cstat->type = CMD_WSTATUS;
|
cstat->type = CMD_WSTATUS;
|
||||||
@@ -468,7 +469,8 @@ handle_signals(int fd, pid_t child, int log_io, struct command_status *cstat)
|
|||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kill(child, signo);
|
if (kill(child, signo) != 0)
|
||||||
|
warning("kill(%d, %d)", child, signo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user