summaryrefslogtreecommitdiffstats
path: root/tests/features/open_and_sleep.c
blob: 7d0e22a2503214846710a7555e1a35b3c7f9a3c3 (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
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>

int
main(int argc, char **argv)
{
    pid_t pid;
    int fd;

    if (argc >= 2) {
        fd = open(argv[1], O_RDWR | O_CREAT, 0644);
        if (fd == -1) {
            fprintf(stderr, "cannot open/create %s\n", argv[1]);
            return 1;
        }
    }

    pid = getpid();
    printf("%d\n", pid);
    fflush(stdout);

    for (;;)
        sleep(1);

    return 0;
}