4.marko.18_test.coder 4.karina.18_test.coder

--- 4.marko.18_test.coder.fmt.c	2020-06-08 11:39:11.774116099 +0300
+++ 4.karina.18_test.coder.fmt.c	2020-06-08 11:39:11.758115926 +0300
@@ -1,33 +1,29 @@
 #1 "<stdin>"
 #include <stdio.h>
-#include <sys/types.h>
+#include <string.h>
 #include <signal.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <string.h>
-#include <unistd.h>
 int main(int argc, char *argv[]) {
-    int i = 0;
-    int m = 128;
+    int signal = 0;
     while (1) {
-	char c = argv[2][i];
-	char cc = c;
-	for (int j = 0; j < 8; j++) {
-	    int sign;
-	    if ((m & c) == 128)
-		sign = SIGUSR2;
+	char c0 = argv[2][signal];
+	char c1 = argv[2][signal];
+	int PID = (atoi(argv[1]));
+	for (int i = 7; i >= 0; i--) {
+	    int a = (c0 >> (i)) & 0x1;
+	    if (a == 1)
+		kill(PID, SIGUSR2);
 	    else
-		sign = SIGUSR1;
-	    if (kill(atoi(argv[1]), sign)) {
-		perror("Kill problem:");
-		exit(1);
-	    }
-	    usleep(1000);
-	    c = c << 1;
+		kill(PID, SIGUSR1);
+	    usleep(10000);
+	    c0 = c0 << 1;
 	}
-	if (cc == '\0')
+	if (c1 == 0)
 	    break;
-	i++;
+	signal++;
     }
     return 0;
 }