Files
MontaukOS/template/sysroot/include/libc/spawn.h
T

61 lines
2.0 KiB
C

#ifndef _LIBC_SPAWN_H
#define _LIBC_SPAWN_H
#pragma once
#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* posix_spawn for MontaukOS, layered on SYS_SPAWN.
*
* Limitations (kernel spawn model):
* - argv is joined into a single args string; arguments containing
* spaces are rejected with EINVAL (no quoting in the kernel).
* - envp is ignored (no environment transfer on spawn).
* - file actions must be empty: stdio redirection needs kernel
* support that does not exist yet, so any recorded action makes
* posix_spawn fail with ENOTSUP rather than misbehave silently.
*/
typedef struct {
short flags;
} posix_spawnattr_t;
typedef struct {
int action_count;
} posix_spawn_file_actions_t;
int posix_spawnattr_init(posix_spawnattr_t *attr);
int posix_spawnattr_destroy(posix_spawnattr_t *attr);
int posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags);
int posix_spawnattr_getflags(const posix_spawnattr_t *attr, short *flags);
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *actions);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *actions);
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *actions,
int fd, int newfd);
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *actions,
int fd);
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *actions,
int fd, const char *path, int oflag,
mode_t mode);
int posix_spawn(pid_t *pid, const char *path,
const posix_spawn_file_actions_t *actions,
const posix_spawnattr_t *attr,
char *const argv[], char *const envp[]);
int posix_spawnp(pid_t *pid, const char *file,
const posix_spawn_file_actions_t *actions,
const posix_spawnattr_t *attr,
char *const argv[], char *const envp[]);
#ifdef __cplusplus
}
#endif
#endif /* _LIBC_SPAWN_H */