1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| | #include <spawn.h>
#include <string.h>
#include <errno.h>
#include "fdop.h"
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
{
size_t len;
if (fd < 0) return EBADF;
len = strlen(path);
if (__faexpand(fa, len + 1) != 0) return ENOMEM;
fa->fa_ops[fa->fa_cnt++] = fd;
fa->fa_ops[fa->fa_cnt++] = -FDOP_OPEN;
fa->fa_ops[fa->fa_cnt++] = flags;
fa->fa_ops[fa->fa_cnt++] = mode;
memcpy((posix_spawn_file_actions_t *)fa->fa_chain + 1, path, len + 1);
return 0;
}
|