-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.c
47 lines (43 loc) · 1.4 KB
/
server.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: binurtas <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/14 18:44:41 by binurtas #+# #+# */
/* Updated: 2023/01/14 18:49:08 by binurtas ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
void ft_handler(int signal)
{
static int bit;
static unsigned char i;
if (signal == SIGONE)
i |= (0x01 << bit);
bit++;
if (bit == 8)
{
ft_printf("%c", i);
bit = 0;
i = 0;
}
}
int main(int ac, char **av)
{
(void)av;
if (ac != 1)
{
ft_printf("You should use like this :\n./server");
return (0);
}
ft_printf("PID : %d\n", getpid());
while (ac == 1)
{
signal(SIGONE, ft_handler);
signal(SIGZERO, ft_handler);
pause();
}
return (0);
}