1#include <dirent.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <sys/stat.h>
5#include <fcntl.h>
6#include <errno.h>
7
8int
9main(int argc, char** argv)
10{
11	const char* filename = "temp.fifo";
12
13	if (mkfifo("temp.fifo", S_IRWXU) != 0) {
14		perror("mkfifo error");
15		return 1;
16	}
17
18	int rfd = open(filename, O_RDONLY | O_NONBLOCK);
19	if (rfd < 0) {
20		perror("open() error");
21		return 1;
22	}
23
24	DIR* dir = opendir(filename);
25	if (dir != NULL) {
26		perror("opendir succeeded");
27		return 1;
28	}
29
30	dir = fdopendir(rfd);
31	if (dir != NULL) {
32		perror("fdopendir succeeded");
33		return 1;
34	}
35
36	unlink(filename);
37	return 0;
38}
39