File: eventfd.c

package info (click to toggle)
lsof 4.99.4%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,924 kB
  • sloc: ansic: 50,680; sh: 8,351; makefile: 1,194; perl: 940; awk: 214
file content (29 lines) | stat: -rw-r--r-- 537 bytes parent folder | download
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
#include <sys/eventfd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>

static int fd = -1;

int main(int argc, char **argv) {
    fd = eventfd(0, 0);
    if (fd < 0) {
        perror("eventfd");
        return -1;
    }

    pid_t pid = fork();
    if (pid < 0) {
        perror("fork");
        return -1;
    } else if (pid == 0) {
        pause();
    } else {
        printf("%d %d %d\n", getpid(), pid, fd);
        fflush(stdout);
        wait(NULL);
    }
    return 0;
}