4.ilyaz.18_test.coder 4.egor.18_test.coder

--- 4.ilyaz.18_test.coder.fmt.c	2020-06-08 11:39:11.742115753 +0300
+++ 4.egor.18_test.coder.fmt.c	2020-06-08 11:39:11.727115591 +0300
@@ -1,25 +1,29 @@
 #1 "<stdin>"
-#include <stdio.h>
+#include <string.h>
+#include <errno.h>
 #include <sys/types.h>
-#include <signal.h>
 #include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
 #include <stdlib.h>
-#include <string.h>
 int main(int argc, char *argv[]) {
-    char *c = argv[2];
-    int pid;
-    sscanf(argv[1], "%d", &pid);
-    int len = strlen(c) + 1;
-    *(c + len) = '\0';
-    for (int i = 0; i < len; ++i) {
-	for (int j = 7; j >= 0; --j) {
-	    int byte = (c[i] >> j) & 1;
-	    if (byte == 1)
+    int sygnal = 0;
+    while (1) {
+	char zero = argv[2][sygnal];
+	char one = argv[2][sygnal];
+	int pid = (atoi(argv[1]));
+	for (int k = 7; k >= 0; k--) {
+	    int x = (zero >> (k)) & 0x1;
+	    if (x == 1)
 		kill(pid, SIGUSR2);
 	    else
 		kill(pid, SIGUSR1);
-	    usleep(1000);
+	    usleep(10000);
+	    zero = zero << 1;
 	}
+	if (one == 0)
+	    break;
+	sygnal++;
     }
     return 0;
 }