blob: 9a9a80e2b003f127262d3c48bffc483cec3d7e87 (
plain)
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
|
#include "sys/ioctl.h"
#include "errno.h"
#include "stdarg.h"
#include "stdio.h"
#include "unistd.h"
#include "string.h"
#include "signal.h"
#include "types.h"
err e33_ioctl( Size fd, unsigned long req, void *arg )
{
Size ret;
do {
ret = ioctl(fd, req, arg);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
return ret;
}
boolean e33_strcmp( String s1, String s2 )
{
while( (*s1 != '\0') && (*s2 != '\0') )
{
if( (*s1++) != (*s2++) ) {
return E33_FALSE;
}
}
return E33_TRUE;
}
err e33_has_signal(Size signo)
{
struct sigaction sact = {0};
sigaction(signo, 0, &sact);
return sact.sa_handler != 0;
}
err e33_set_signal(Size signo, void(*sig_handler)(int))
{
struct sigaction sact = {0};
sact.sa_handler = sig_handler;
sigemptyset(&sact.sa_mask);
sact.sa_flags = SA_RESTART;
return sigaction(signo, &sact, NULL);
}
|