This source file includes following definitions.
- posix_spawn_file_actions_addchdir
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 #include <config.h>
17
18
19 #include <spawn.h>
20
21 #include <errno.h>
22 #include <stdlib.h>
23 #include <string.h>
24
25 #if REPLACE_POSIX_SPAWN
26 # include "spawn_int.h"
27 #endif
28
29
30
31 int
32 posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t *file_actions,
33 const char *path)
34 #undef posix_spawn_file_actions_addchdir
35 {
36 #if !REPLACE_POSIX_SPAWN
37 return posix_spawn_file_actions_addchdir_np (file_actions, path);
38 #else
39 {
40
41
42 char *path_copy = strdup (path);
43 if (path_copy == NULL)
44 return ENOMEM;
45
46
47 if (file_actions->_used == file_actions->_allocated
48 && __posix_spawn_file_actions_realloc (file_actions) != 0)
49 {
50
51 free (path_copy);
52 return ENOMEM;
53 }
54
55 {
56 struct __spawn_action *rec;
57
58
59 rec = &file_actions->_actions[file_actions->_used];
60 rec->tag = spawn_do_chdir;
61 rec->action.chdir_action.path = path_copy;
62
63
64 ++file_actions->_used;
65
66 return 0;
67 }
68 }
69 #endif
70 }