--- 4.lika.18_test.coder.fmt.c 2020-06-08 11:39:11.766116013 +0300
+++ 4.egor.18_test.coder.fmt.c 2020-06-08 11:39:11.727115591 +0300
@@ -1,27 +1,29 @@
#1 "<stdin>"
-#include <stdio.h>
-#include <signal.h>
-#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
+#include <stdio.h>
+#include <signal.h>
+#include <stdlib.h>
int main(int argc, char *argv[]) {
- int i = 0;
+ int sygnal = 0;
while (1) {
- char a = argv[2][i];
- char b = argv[2][i];
- for (int j = 7; j >= 0; j--) {
- int x = (a >> (j)) & 0x1;
+ 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(atoi(argv[1]), SIGUSR2);
+ kill(pid, SIGUSR2);
else
- kill(atoi(argv[1]), SIGUSR1);
- usleep(1000);
+ kill(pid, SIGUSR1);
+ usleep(10000);
+ zero = zero << 1;
}
- if (b == 0)
+ if (one == 0)
break;
- i++;
+ sygnal++;
}
return 0;
}