|
0
|
1 |
#include "select.h"
|
|
|
2 |
#include "open.h"
|
|
|
3 |
#include "trigger.h"
|
|
|
4 |
#include "hasnpbg1.h"
|
|
|
5 |
|
|
|
6 |
static int fd = -1;
|
|
|
7 |
#ifdef HASNAMEDPIPEBUG1
|
|
|
8 |
static int fdw = -1;
|
|
|
9 |
#endif
|
|
|
10 |
|
|
|
11 |
void trigger_set()
|
|
|
12 |
{
|
|
|
13 |
if (fd != -1)
|
|
|
14 |
close(fd);
|
|
|
15 |
#ifdef HASNAMEDPIPEBUG1
|
|
|
16 |
if (fdw != -1)
|
|
|
17 |
close(fdw);
|
|
|
18 |
#endif
|
|
|
19 |
fd = open_read("lock/trigger");
|
|
|
20 |
#ifdef HASNAMEDPIPEBUG1
|
|
|
21 |
fdw = open_write("lock/trigger");
|
|
|
22 |
#endif
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
void trigger_selprep(nfds,rfds)
|
|
|
26 |
int *nfds;
|
|
|
27 |
fd_set *rfds;
|
|
|
28 |
{
|
|
|
29 |
if (fd != -1)
|
|
|
30 |
{
|
|
|
31 |
FD_SET(fd,rfds);
|
|
|
32 |
if (*nfds < fd + 1) *nfds = fd + 1;
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
int trigger_pulled(rfds)
|
|
|
37 |
fd_set *rfds;
|
|
|
38 |
{
|
|
|
39 |
if (fd != -1) if (FD_ISSET(fd,rfds)) return 1;
|
|
|
40 |
return 0;
|
|
|
41 |
}
|