1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

LibC: Add addchdir() / addfchdir() to posix_spawn file actions

This isn't in posix yet, but it is implemented on some platforms
and it will be in a future version:
https://www.austingroupbugs.net/view.php?id=1208
This commit is contained in:
Nico Weber 2020-06-19 16:41:43 -04:00 committed by Andreas Kling
parent 2ddca326be
commit 5208856688
2 changed files with 14 additions and 0 deletions

View file

@ -147,6 +147,18 @@ int posix_spawnp(pid_t* out_pid, const char* path, const posix_spawn_file_action
posix_spawn_child(path, file_actions, attr, argv, envp, execvpe);
}
int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t* actions, const char* path)
{
actions->state->actions.append([path]() { return chdir(path); });
return 0;
}
int posix_spawn_file_actions_addfchdir(posix_spawn_file_actions_t* actions, int fd)
{
actions->state->actions.append([fd]() { return fchdir(fd); });
return 0;
}
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* actions, int fd)
{
actions->state->actions.append([fd]() { return close(fd); });