-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.c
42 lines (38 loc) · 1.26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yohwang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/08 18:15:56 by yohwang #+# #+# */
/* Updated: 2022/06/09 22:54:43 by yohwang ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
void get_signal(int signal)
{
static char byte;
static char bit;
byte *= 2;
if (signal == SIGUSR1)
byte += 1;
bit += 1;
if (bit == 8)
{
write(1, &byte, 1);
bit = 0;
byte = 0;
}
}
int main(void)
{
print_word("pid: ");
print_num(getpid());
print_word("\n");
signal(SIGUSR1, get_signal);
signal(SIGUSR2, get_signal);
while (1)
pause();
return (0);
}