This source file includes following definitions.
- get_environ_assignment
- create_minimal_env
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21
22 #include <unistd.h>
23
24 #include "signature.h"
25 SIGNATURE_CHECK (execle, int, (const char *, const char *, ...));
26
27 #include <stdio.h>
28 #include <string.h>
29
30
31
32 static const char *
33 get_environ_assignment (const char *name)
34 {
35 size_t name_len = strlen (name);
36 char **p;
37 for (p = environ; *p != NULL; p++)
38 {
39 const char *assignment = *p;
40 if (strncmp (assignment, name, name_len) == 0
41 && assignment[name_len] == '=')
42 return assignment;
43 }
44 return NULL;
45 }
46
47
48 static void
49 create_minimal_env (const char *env[5])
50 {
51 const char **p = env;
52 *p++ =
53 #ifdef __CYGWIN__
54
55 "PATH=.:/bin";
56 #else
57 "PATH=.";
58 #endif
59 *p = get_environ_assignment ("QEMU_LD_PREFIX");
60 if (*p != NULL)
61 p++;
62 *p = get_environ_assignment ("QEMU_CPU");
63 if (*p != NULL)
64 p++;
65 *p++ = "Hommingberg=Gepardenforelle";
66 *p = NULL;
67 }
68
69 int
70 main ()
71 {
72 const char *progname = "./test-exec-child";
73 const char *env[5];
74 create_minimal_env (env);
75 execle (progname,
76 progname,
77 "abc def",
78 "abc\"def\"ghi",
79 "xyz\"",
80 "abc\\def\\ghi",
81 "xyz\\",
82 "???",
83 "***",
84 "",
85 "foo",
86 "",
87 NULL,
88 env);
89
90 perror ("execle");
91 return 1;
92 }