-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.c
46 lines (41 loc) · 1.45 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aaslan <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/24 13:47:27 by aaslan #+# #+# */
/* Updated: 2023/01/04 04:18:21 by aaslan ### ########.fr */
/* */
/* ************************************************************************** */
#include "utilities/utilities.h"
void ft_print_server_id(int server_id)
{
ft_print_string("Server ID : ");
ft_print_integer(server_id);
ft_print_char('\n');
}
void ft_receive_signal(int signal)
{
static int bit_index = 0;
static char character = 0;
if (signal == SIGUSR1)
character = character | 1 << bit_index;
bit_index++;
if (bit_index == 8)
{
ft_print_char(character);
bit_index = 0;
character = 0;
}
}
int main(void)
{
ft_print_server_id(getpid());
signal(SIGUSR1, ft_receive_signal);
signal(SIGUSR2, ft_receive_signal);
while (1)
pause();
return (0);
}