Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / functionalities / avoids-fd-leak / main.c
blob5bdf227928edc75446e48340019a37ae915389c5
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <unistd.h>
4 #include <errno.h>
5 #include <stdio.h>
7 int
8 main (int argc, char const **argv)
10 struct stat buf;
11 int i, rv = 0; // Set breakpoint here.
13 // Make sure stdin/stdout/stderr exist.
14 for (i = 0; i <= 2; ++i) {
15 if (fstat(i, &buf) != 0)
16 return 1;
19 // Make sure no other file descriptors are open.
20 for (i = 3; i <= 256; ++i) {
21 if (fstat(i, &buf) == 0 || errno != EBADF) {
22 fprintf(stderr, "File descriptor %d is open.\n", i);
23 rv = 2;
27 return rv;