PostgreSQL Source Code git master
Loading...
Searching...
No Matches
test_cloexec.c File Reference
#include "postgres.h"
#include <fcntl.h>
#include <sys/stat.h>
#include "common/file_utils.h"
#include "port.h"
Include dependency graph for test_cloexec.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char argv[] 
)

Definition at line 34 of file test_cloexec.c.

35{
36 /* Windows-only test */
37#ifndef WIN32
38 fprintf(stderr, "This test only runs on Windows\n");
39 return 0;
40#else
41 char testfile1[MAXPGPATH];
42 char testfile2[MAXPGPATH];
43
44 if (argc == 3)
45 {
46 /*
47 * Child mode: receives two handle values as hex strings and attempts
48 * to write to them.
49 */
50 run_child_tests(argv[1], argv[2]);
51 return 0;
52 }
53 else if (argc == 1)
54 {
55 /* Parent mode: opens files and spawns child */
56 snprintf(testfile1, sizeof(testfile1), "test_cloexec_1_%d.tmp", (int) getpid());
57 snprintf(testfile2, sizeof(testfile2), "test_cloexec_2_%d.tmp", (int) getpid());
58
60
61 /* Clean up test files */
64
65 return 0;
66 }
67 else
68 {
69 fprintf(stderr, "Usage: %s [handle1_hex handle2_hex]\n", argv[0]);
70 return 1;
71 }
72#endif
73}
#define fprintf(file, fmt, msg)
Definition cubescan.l:21
#define MAXPGPATH
#define snprintf
Definition port.h:260
static int fb(int x)

References fb(), fprintf, MAXPGPATH, and snprintf.