123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include <errno.h>
- #include <spawn.h>
- #include <unistd.h>
- #include "spawn_int.h"
- int
- posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *file_actions,
- int fd)
- {
- 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_close;
- rec->action.open_action.fd = fd;
-
- ++file_actions->__used;
- return 0;
- }
|