diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-05-29 12:58:02 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-05-29 12:58:02 -0400 |
commit | f48832ee15027763826c8a7ff9eeed3fc06bb499 (patch) | |
tree | c22fc7561126476e81dfd1f985d4168726a8cfab /src/process | |
parent | dd45edb5ff6198493edf1315d3e4e6ffc7b96447 (diff) | |
download | musl-f48832ee15027763826c8a7ff9eeed3fc06bb499.tar.gz musl-f48832ee15027763826c8a7ff9eeed3fc06bb499.tar.bz2 musl-f48832ee15027763826c8a7ff9eeed3fc06bb499.tar.xz musl-f48832ee15027763826c8a7ff9eeed3fc06bb499.zip |
fix backwards posix_spawn file action order
Diffstat (limited to 'src/process')
-rw-r--r-- | src/process/fdop.h | 2 | ||||
-rw-r--r-- | src/process/posix_spawn.c | 5 | ||||
-rw-r--r-- | src/process/posix_spawn_file_actions_addclose.c | 3 | ||||
-rw-r--r-- | src/process/posix_spawn_file_actions_adddup2.c | 3 | ||||
-rw-r--r-- | src/process/posix_spawn_file_actions_addopen.c | 3 |
5 files changed, 10 insertions, 6 deletions
diff --git a/src/process/fdop.h b/src/process/fdop.h index 72f9b5fe..02ff83c5 100644 --- a/src/process/fdop.h +++ b/src/process/fdop.h @@ -3,7 +3,7 @@ #define FDOP_OPEN 3 struct fdop { - struct fdop *next; + struct fdop *next, *prev; int cmd, fd, newfd, oflag; mode_t mode; char path[]; diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c index 59f4a8bb..b1a9fbde 100644 --- a/src/process/posix_spawn.c +++ b/src/process/posix_spawn.c @@ -51,10 +51,11 @@ int __posix_spawnx(pid_t *res, const char *path, __syscall(SYS_setuid, __syscall(SYS_getuid)) )) _exit(127); - if (fa) { + if (fa && fa->__actions) { struct fdop *op; int ret, fd; - for (op = fa->__actions; op; op = op->next) { + for (op = fa->__actions; op->next; op = op->next); + for (; op; op = op->prev) { switch(op->cmd) { case FDOP_CLOSE: ret = __syscall(SYS_close, op->fd); diff --git a/src/process/posix_spawn_file_actions_addclose.c b/src/process/posix_spawn_file_actions_addclose.c index 44c6314f..cdda5979 100644 --- a/src/process/posix_spawn_file_actions_addclose.c +++ b/src/process/posix_spawn_file_actions_addclose.c @@ -9,7 +9,8 @@ int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, int fd) if (!op) return ENOMEM; op->cmd = FDOP_CLOSE; op->fd = fd; - op->next = fa->__actions; + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; fa->__actions = op; return 0; } diff --git a/src/process/posix_spawn_file_actions_adddup2.c b/src/process/posix_spawn_file_actions_adddup2.c index 9209ee7c..26f2c5cc 100644 --- a/src/process/posix_spawn_file_actions_adddup2.c +++ b/src/process/posix_spawn_file_actions_adddup2.c @@ -10,7 +10,8 @@ int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int fd, int op->cmd = FDOP_DUP2; op->fd = fd; op->newfd = newfd; - op->next = fa->__actions; + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; fa->__actions = op; return 0; } diff --git a/src/process/posix_spawn_file_actions_addopen.c b/src/process/posix_spawn_file_actions_addopen.c index 5e2c86d9..af3ca604 100644 --- a/src/process/posix_spawn_file_actions_addopen.c +++ b/src/process/posix_spawn_file_actions_addopen.c @@ -13,7 +13,8 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, con op->oflag = flags; op->mode = mode; strcpy(op->path, path); - op->next = fa->__actions; + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; fa->__actions = op; return 0; } |