posix_spawn_file_actions_addclose.c 361 B

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