12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #include <errno.h>
- #include <spawn.h>
- #include <unistd.h>
- #include "spawn_int.h"
- int
- posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *file_actions,
- int fd, const char *path, int oflag,
- mode_t mode)
- {
- int maxfd = sysconf(_SC_OPEN_MAX);
- struct __spawn_action *rec;
-
- if (fd < 0 || fd >= maxfd)
- return EBADF;
-
- if (file_actions->__used == file_actions->__allocated
- && __posix_spawn_file_actions_realloc (file_actions) != 0)
-
- return ENOMEM;
-
- rec = &file_actions->__actions[file_actions->__used];
- rec->tag = spawn_do_open;
- rec->action.open_action.fd = fd;
- rec->action.open_action.path = path;
- rec->action.open_action.oflag = oflag;
- rec->action.open_action.mode = mode;
-
- ++file_actions->__used;
- return 0;
- }
|