1 #include <spawn.h> 2 #include <stdlib.h> 3 #include <errno.h> 4 #include "fdop.h" 5 #include <unsupported_api.h> 6 posix_spawn_file_actions_addclose(posix_spawn_file_actions_t * fa,int fd)7int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd) 8 { 9 if (fd < 0) return EBADF; 10 UNSUPPORTED_API_VOID(LITEOS_A); 11 struct fdop *op = malloc(sizeof *op); 12 if (!op) return ENOMEM; 13 op->cmd = FDOP_CLOSE; 14 op->fd = fd; 15 if ((op->next = fa->__actions)) op->next->prev = op; 16 op->prev = 0; 17 fa->__actions = op; 18 return 0; 19 } 20