1 /* Copyright (C) 2018 Free Software Foundation, Inc.
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 3 of the License, or
6 (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <https://www.gnu.org/licenses/>. */
23 #if REPLACE_POSIX_SPAWN
24 # include "spawn_int.h"
27 /* Add an action to FILE-ACTIONS which tells the implementation to call
28 'chdir' to the given directory during the 'spawn' call. */
30 posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t
*file_actions
,
32 #undef posix_spawn_file_actions_addchdir
34 #if !REPLACE_POSIX_SPAWN
35 return posix_spawn_file_actions_addchdir_np (file_actions
, path
);
37 /* Allocate more memory if needed. */
38 if (file_actions
->_used
== file_actions
->_allocated
39 && __posix_spawn_file_actions_realloc (file_actions
) != 0)
40 /* This can only mean we ran out of memory. */
44 struct __spawn_action
*rec
;
46 /* Add the new value. */
47 rec
= &file_actions
->_actions
[file_actions
->_used
];
48 rec
->tag
= spawn_do_chdir
;
49 rec
->action
.chdir_action
.path
= path
;
51 /* Account for the new entry. */
52 ++file_actions
->_used
;