--- 4.marko.18_test.coder.fmt.c 2020-06-08 11:39:11.774116099 +0300
+++ 4.lika.18_test.coder.fmt.c 2020-06-08 11:39:11.766116013 +0300
@@ -1,31 +1,25 @@
#1 "<stdin>"
#include <stdio.h>
-#include <sys/types.h>
#include <signal.h>
#include <stdlib.h>
-#include <errno.h>
#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int i = 0;
- int m = 128;
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 a = argv[2][i];
+ char b = argv[2][i];
+ for (int j = 7; j >= 0; j--) {
+ int x = (a >> (j)) & 0x1;
+ if (x == 1)
+ kill(atoi(argv[1]), SIGUSR2);
else
- sign = SIGUSR1;
- if (kill(atoi(argv[1]), sign)) {
- perror("Kill problem:");
- exit(1);
- }
+ kill(atoi(argv[1]), SIGUSR1);
usleep(1000);
- c = c << 1;
}
- if (cc == '\0')
+ if (b == 0)
break;
i++;
}