#include #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->__pad[fa->__pad0[0]++] = fd; fa->__pad[fa->__pad0[0]++] = -FDOP_OPEN; fa->__pad[fa->__pad0[0]++] = flags; fa->__pad[fa->__pad0[0]++] = mode; memcpy((posix_spawn_file_actions_t *)fa->__actions + 1, path, len + 1); return 0; }