fixes for Power64
[tridge/junkcode.git] / spair_fork.c
1 #include <sys/types.h>
2 #include <signal.h>
3 #include <errno.h>
4 #include <unistd.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <fcntl.h>
8 #include <sys/socket.h>
9
10 static int dispatch_daemon(int fd)
11 {
12         int epoll_fd = epoll_create(64);
13         struct epoll_event event;
14         int v;
15
16         while (read(fd, &v, sizeof(v)) == 
17
18 }
19
20
21 int main(void) 
22
23        int fd[2];
24        int i;
25        const int n = 10;
26
27        setpgrp();
28
29        if (socketpair(AF_UNIX, SOCK_DGRAM, 0, fd) != 0) {
30                perror("socketpair");
31                exit(1);
32        }
33
34        if (fork() == 0) {
35                close(fd[0]);
36                dispatch_daemon(fd[1]);
37        }
38
39        for (i=0;i<n;i++) {
40                if (fork() == 0) {
41                        close(fd[1]);
42                        client(fd[0]);
43                }
44        }
45        close(fd[0]);
46        close(fd[1]);
47
48        sleep(10);
49        
50        kill(-getpid(), SIGTERM);
51        return 0;
52