• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _FDLEAK_H_
2 #define _FDLEAK_H_
3 
4 #include <stdlib.h>
5 #include <stdio.h>
6 
7 #define DO(op) \
8    ({ \
9       long res = op; \
10       if (res < 0) { \
11          perror(#op); \
12          exit(1); \
13       }; \
14       res; \
15    })
16 
17 /*
18  * The macro below closes file descriptors inherited from the process
19  * that forked the current process. Close these file descriptors right
20  * after the start of main() in order to get consistent results across
21  * different releases. Known behavior:
22  * - Fedora Core 1's Perl opens /dev/pts/2 as fd 10.
23  * - For Ubuntu 8.04, see also
24  *   https://bugs.launchpad.net/ubuntu/+source/seahorse/+bug/235184
25  */
26 #define CLOSE_INHERITED_FDS { int i; for (i = 3; i < 64; i++) close(i); }
27 
28 #endif /* _FDLEAK_H_ */
29