-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.c
More file actions
50 lines (45 loc) · 1.35 KB
/
client.c
File metadata and controls
50 lines (45 loc) · 1.35 KB
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
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* client.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alisharu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/22 21:05:29 by alisharu #+# #+# */
/* Updated: 2025/11/22 21:05:31 by alisharu ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_minitalk.h"
void send_sig(int pid, char *str)
{
int bit;
char c;
int i;
i = 0;
bit = 0;
while (str[i] != '\0')
{
c = str[i];
while (bit < 8)
{
if (c & 0b00000001)
kill(pid, SIGUSR1);
else
kill(pid, SIGUSR2);
c >>= 1;
bit++;
usleep(100);
}
i++;
bit = 0;
}
}
int main(int ac, char **av)
{
int pid;
if (ac != 3)
return (ft_printf("client: invalid arguments \n"));
pid = ft_atoi(av[1]);
send_sig(pid, av[2]);
return (0);
}