posix_spawn_file_actions_adddup2.c 390 B

1234567891011121314151617
  1. #include <spawn.h>
  2. #include <stdlib.h>
  3. #include <errno.h>
  4. #include "fdop.h"
  5. int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int fd, int newfd)
  6. {
  7. struct fdop *op = malloc(sizeof *op);
  8. if (!op) return ENOMEM;
  9. op->cmd = FDOP_DUP2;
  10. op->fd = fd;
  11. op->newfd = newfd;
  12. if ((op->next = fa->__actions)) op->next->prev = op;
  13. op->prev = 0;
  14. fa->__actions = op;
  15. return 0;
  16. }