1570af302Sopenharmony_ci#include <spawn.h> 2570af302Sopenharmony_ci#include <stdlib.h> 3570af302Sopenharmony_ci#include <errno.h> 4570af302Sopenharmony_ci#include "fdop.h" 5570af302Sopenharmony_ci#include <unsupported_api.h> 6570af302Sopenharmony_ci 7570af302Sopenharmony_ciint posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int srcfd, int fd) 8570af302Sopenharmony_ci{ 9570af302Sopenharmony_ci if (srcfd < 0 || fd < 0) return EBADF; 10570af302Sopenharmony_ci UNSUPPORTED_API_VOID(LITEOS_A); 11570af302Sopenharmony_ci struct fdop *op = malloc(sizeof *op); 12570af302Sopenharmony_ci if (!op) return ENOMEM; 13570af302Sopenharmony_ci op->cmd = FDOP_DUP2; 14570af302Sopenharmony_ci op->srcfd = srcfd; 15570af302Sopenharmony_ci op->fd = fd; 16570af302Sopenharmony_ci if ((op->next = fa->__actions)) op->next->prev = op; 17570af302Sopenharmony_ci op->prev = 0; 18570af302Sopenharmony_ci fa->__actions = op; 19570af302Sopenharmony_ci return 0; 20570af302Sopenharmony_ci} 21