-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.c
More file actions
58 lines (52 loc) · 1.49 KB
/
server.c
File metadata and controls
58 lines (52 loc) · 1.49 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
51
52
53
54
55
56
57
58
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: alisharu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/22 21:06:15 by alisharu #+# #+# */
/* Updated: 2025/11/22 21:06:16 by alisharu ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_minitalk.h"
void man_signal(int signal)
{
static int i = 0;
static unsigned char binary;
static unsigned char bit;
if (signal == SIGUSR1)
{
binary = 1;
bit = bit | (binary << i);
i++;
}
else if (signal == SIGUSR2)
{
binary = 0;
bit = bit | (binary << i);
i++;
}
if (i == 8)
{
write(1, &bit, 1);
bit = 0;
i = 0;
}
}
void ft_sig(void)
{
struct sigaction a;
a.sa_handler = &man_signal;
a.sa_flags = SA_SIGINFO;
sigaction(SIGUSR1, &a, NULL);
sigaction(SIGUSR2, &a, NULL);
}
int main(void)
{
ft_printf("Your pid is: %d\n", getpid());
ft_sig();
while (1)
pause();
return (0);
}