From a65097654a8c0ee189e00f9a1ab85219561f8961 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 9 Jan 2026 10:00:22 +0100 Subject: [PATCH] feat: kill process and complete main() --- main.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index eb3a40d..b4c3361 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -43,15 +44,27 @@ int pick_random_process(int *processes, int count) { return processes[rand() % count]; } +int kill_process(int process) { return kill(process, SIGKILL); } + int main(void) { + if (getuid() != 0) { + printf( + "You're not bold enought to run this program as root, interesting.\n"); + } + srand(time(NULL) ^ getpid()); int count; int *processes = get_running_processes(&count); if (!processes || count == 0) { return 1; } + int process = pick_random_process(processes, count); - printf("Process %d is nominated for termination.\n", process); free(processes); - return 0; + if (kill_process(process) != 0) { + perror("Abort killing order."); + return 1; + } + + return process; // now you get it }