-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.c
49 lines (44 loc) · 1.35 KB
/
client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fvieira <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/09 15:44:35 by fvieira #+# #+# */
/* Updated: 2022/12/13 17:39:18 by fvieira ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
void sendsignal(char *str, pid_t p)
{
int count;
unsigned char c;
int bit;
count = 0;
while (str[count] != '\0')
{
c = (unsigned char) str[count];
bit = 0;
while (bit < 8)
{
if (c & 0b00000001)
kill(p, SIGUSR1);
else
kill(p, SIGUSR2);
c >>= 1;
bit++;
usleep(30);
}
count++;
}
}
int main(int argc, char **argv)
{
pid_t p;
if (argc != 3)
return (0);
p = ft_atoi(argv[1]);
sendsignal(argv[2], p);
return (0);
}