diff --git a/tests/signals/kill-child.c b/tests/signals/kill-child.c index 809564789c..deefb271ed 100644 --- a/tests/signals/kill-child.c +++ b/tests/signals/kill-child.c @@ -85,7 +85,7 @@ int main() for (int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++) { int sig = signals_list[i].signal; - if (sig == SIGKILL || i == SIGSTOP) + if (sig == SIGKILL || sig == SIGSTOP) { continue; } diff --git a/tests/signals/kill-group.c b/tests/signals/kill-group.c index cde477390e..17ae2fb895 100644 --- a/tests/signals/kill-group.c +++ b/tests/signals/kill-group.c @@ -5,10 +5,12 @@ #include "signals_list.h" #include "../test_helpers.h" +// this test is to make sure that when a negative pid is supplied to kill, all the processes in that group will be killed + +int handler_called = 0; void sig_handler(int signo) { - printf("Caught signal %d being tested!\n", signo); - printf("Test PASSED\n"); + handler_called = 1; return; } @@ -24,18 +26,20 @@ int kill_group(int signum) ERROR_IF(sigemptyset, status, == -1); status = sigaction(signum, &act, 0); - ERROR_IF(sigaction, staus, == -1); + ERROR_IF(sigaction, status, == -1); - staus = getpgrp(); + status = getpgrp(); ERROR_IF(getpgrp, status, == -1); status = kill(-pgrp, signum); - ERROR_IF(kill, staus, != 0); + ERROR_IF(kill, status, != 0); + + ERROR_IF(kill, handler_called, !=1); + handler_called = 0; return EXIT_SUCCESS; } -// If pid is negative, but not -1, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal. int main() { for (unsigned int i = 0; i < sizeof(signals_list)/sizeof(signals_list[0]); i++) diff --git a/tests/signals/kill-permission.c b/tests/signals/kill-permission.c index bad0a625f8..eab0aef545 100644 --- a/tests/signals/kill-permission.c +++ b/tests/signals/kill-permission.c @@ -6,13 +6,15 @@ #include #include "../test_helpers.h" +// makes sure that a process is not killed if the user doesn't have permission to kill the process + int main(void) { int status; - // This is added incase user is root. If user is normal user, then it has no effect on the tests + // This is added in case user is root. If user is normal user, then it has no effect on the tests setuid(1000); status = kill(1, 0); ERROR_IF(kill, status, != -1); - ERROR_IF(kill, errno, !=EPERM); + ERROR_IF(kill, errno, != EPERM); return EXIT_SUCCESS; } \ No newline at end of file diff --git a/tests/signals/killpg-child.c b/tests/signals/killpg-child.c index 1cec7b8607..4cad327632 100644 --- a/tests/signals/killpg-child.c +++ b/tests/signals/killpg-child.c @@ -68,7 +68,7 @@ int main(){ for (unsigned int i = 1; i < sizeof(signals_list)/sizeof(signals_list[0]); i++) { int sig = signals_list[i].signal; - if (sig == SIGKILL || sig == SIGSTOP || sig == SIGCHLD) + if (sig == SIGKILL || sig == SIGSTOP || sig == SIGCHLD || sig == SIGINT || sig == SIGQUIT) { continue; } diff --git a/tests/signals/sigrelse-3.c b/tests/signals/sigrelse-3.c index 863d592ffe..980bca35bd 100644 --- a/tests/signals/sigrelse-3.c +++ b/tests/signals/sigrelse-3.c @@ -1,9 +1,8 @@ -#define _XOPEN_SOURCE 700 - #include #include #include #include +#include "../test_helpers.h" int main() { @@ -12,14 +11,4 @@ int main() ERROR_IF(sigrelse, status, != -1); ERROR_IF(sigrelse, errno, != EINVAL); return EXIT_SUCCESS; - // if ((int)sigrelse(100000) == -1) { - - // if (EINVAL == errno) { - // printf ("errno set to EINVAL\n"); - // return EXIT_SUCCESS; - // } else { - // printf ("errno not set to EINVAL\n"); - // exit(EXIT_FAILURE); - // } - // } } \ No newline at end of file