-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.c
41 lines (37 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bkaztaou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/09 04:28:43 by bkaztaou #+# #+# */
/* Updated: 2023/07/10 01:39:18 by bkaztaou ### ########.fr */
/* */
/* ************************************************************************** */
#include "./ft_printf/ft_printf.h"
#include "minitalk.h"
void handle_signal(int sig)
{
static unsigned char c;
static int bites_count;
c = ((sig == SIGUSR2) << bites_count) | c;
bites_count++;
if (bites_count == 8)
{
write(1, &c, 1);
c = 0;
bites_count = 0;
}
}
int main(void)
{
ft_printf("PID: %d\n", getpid());
while (1)
{
signal(SIGUSR1, handle_signal);
signal(SIGUSR2, handle_signal);
pause();
}
return (0);
}