Browse Source

kill(2): sets errno

K. Lange 4 years ago
parent
commit
9c30e8263d
2 changed files with 7 additions and 6 deletions
  1. 5 5
      kernel/sys/signal.c
  2. 2 1
      libc/signal/kill.c

+ 5 - 5
kernel/sys/signal.c

@@ -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 */

+ 2 - 1
libc/signal/kill.c

@@ -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));
 }