mirror of https://git.musl-libc.org/git/musl
5 changed files with 85 additions and 2 deletions
@ -0,0 +1,15 @@ |
|||
#include <spawn.h> |
|||
#include <stdlib.h> |
|||
#include <errno.h> |
|||
#include "fdop.h" |
|||
|
|||
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd) |
|||
{ |
|||
struct fdop *op = malloc(sizeof *op); |
|||
if (!op) return ENOMEM; |
|||
op->cmd = FDOP_CLOSE; |
|||
op->fd = fd; |
|||
op->next = fa->__actions; |
|||
fa->__actions = op; |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
#include <spawn.h> |
|||
#include <stdlib.h> |
|||
#include <errno.h> |
|||
#include "fdop.h" |
|||
|
|||
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int fd, int newfd) |
|||
{ |
|||
struct fdop *op = malloc(sizeof *op); |
|||
if (!op) return ENOMEM; |
|||
op->cmd = FDOP_DUP2; |
|||
op->fd = fd; |
|||
op->newfd = newfd; |
|||
op->next = fa->__actions; |
|||
fa->__actions = op; |
|||
return 0; |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
#include <spawn.h> |
|||
#include <stdlib.h> |
|||
#include <string.h> |
|||
#include <errno.h> |
|||
#include "fdop.h" |
|||
|
|||
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, const char *path, int flags, mode_t mode) |
|||
{ |
|||
struct fdop *op = malloc(sizeof *op + strlen(path) + 1); |
|||
if (!op) return ENOMEM; |
|||
op->cmd = FDOP_OPEN; |
|||
op->fd = fd; |
|||
op->oflag = flags; |
|||
op->mode = mode; |
|||
strcpy(op->path, path); |
|||
op->next = fa->__actions; |
|||
fa->__actions = op; |
|||
return 0; |
|||
} |
|||
@ -1,9 +1,14 @@ |
|||
#include <spawn.h> |
|||
#include <stdlib.h> |
|||
#include "fdop.h" |
|||
|
|||
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *fa) |
|||
{ |
|||
// FIXME
|
|||
free(fa->__actions); |
|||
struct fdop *op = fa->__actions, *next; |
|||
while (op) { |
|||
next = op->next; |
|||
free(op); |
|||
op = next; |
|||
} |
|||
return 0; |
|||
} |
|||
|
|||
Loading…
Reference in new issue