#include #include #include #include "fdop.h" int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode) { size_t len; if (fd < 0) return EBADF; len = strlen(path); if (__faexpand(fa, len + 1) != 0) return ENOMEM; fa->fa_ops[fa->fa_cnt++] = fd; fa->fa_ops[fa->fa_cnt++] = -FDOP_OPEN; fa->fa_ops[fa->fa_cnt++] = flags; fa->fa_ops[fa->fa_cnt++] = mode; memcpy((posix_spawn_file_actions_t *)fa->fa_chain + 1, path, len + 1); return 0; }