kill(2): sets errno

This commit is contained in:
K. Lange 2018-10-08 10:23:10 +09:00
parent 3e14c62bdc
commit 9c30e8263d
2 changed files with 7 additions and 6 deletions

View File

@ -188,27 +188,27 @@ int send_signal(pid_t process, uint32_t signal, int force_root) {
if (!receiver) {
/* Invalid pid */
return 1;
return -ESRCH;
}
if (!force_root && receiver->user != current_process->user && current_process->user != USER_ROOT_UID) {
/* No way in hell. */
return 1;
return -EPERM;
}
if (signal > NUMSIGNALS) {
/* Invalid signal */
return 1;
return -EINVAL;
}
if (receiver->finished) {
/* Can't send signals to finished processes */
return 1;
return -EINVAL;
}
if (!receiver->signals.functions[signal] && !isdeadly[signal]) {
/* If we're blocking a signal and it's not going to kill us, don't deliver it */
return 1;
return 0;
}
/* Append signal to list */

View File

@ -1,9 +1,10 @@
#include <signal.h>
#include <syscall.h>
#include <errno.h>
DEFN_SYSCALL2(send_signal, 37, uint32_t, uint32_t);
int kill(int pid, int sig) {
return syscall_send_signal(pid, sig);
__sets_errno(syscall_send_signal(pid, sig));
}