66 lines
2.8 KiB
C
66 lines
2.8 KiB
C
// nt-lite posix_spawn declarations.
|
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <sys/types.h>
|
|
#include <signal.h>
|
|
#include <ntlite_posix_api.h>
|
|
|
|
#define POSIX_SPAWN_SETPGROUP 0x00000001u
|
|
#define POSIX_SPAWN_SETSIGMASK 0x00000002u
|
|
#define POSIX_SPAWN_SETSIGDEF 0x00000004u
|
|
#define POSIX_SPAWN_FILE_ACTION_CAPACITY 64u
|
|
|
|
#define NTL_POSIX_SPAWN_FILE_ACTION_NONE 0u
|
|
#define NTL_POSIX_SPAWN_FILE_ACTION_CLOSE 1u
|
|
#define NTL_POSIX_SPAWN_FILE_ACTION_DUP2 2u
|
|
#define NTL_POSIX_SPAWN_FILE_ACTION_OPEN 3u
|
|
|
|
typedef struct posix_spawn_file_action_entry {
|
|
uint32_t Type;
|
|
int FileDescriptor;
|
|
int NewFileDescriptor;
|
|
int OpenFlags;
|
|
mode_t Mode;
|
|
char* Path;
|
|
} posix_spawn_file_action_entry;
|
|
|
|
typedef struct posix_spawn_file_actions_t {
|
|
uint32_t Initialized;
|
|
uint32_t Count;
|
|
posix_spawn_file_action_entry Entries[POSIX_SPAWN_FILE_ACTION_CAPACITY];
|
|
} posix_spawn_file_actions_t;
|
|
|
|
typedef struct posix_spawnattr_t {
|
|
uint32_t Initialized;
|
|
uint32_t Flags;
|
|
pid_t ProcessGroup;
|
|
sigset_t SignalMask;
|
|
sigset_t SignalDefault;
|
|
} posix_spawnattr_t;
|
|
|
|
NTL_POSIX_API int posix_spawn_file_actions_init(posix_spawn_file_actions_t* actions);
|
|
NTL_POSIX_API int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t* actions);
|
|
NTL_POSIX_API int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t* actions, int fd);
|
|
NTL_POSIX_API int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t* actions,
|
|
int fd, int newFd);
|
|
NTL_POSIX_API int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t* actions, int fd,
|
|
const char* path, int openFlags, mode_t mode);
|
|
|
|
NTL_POSIX_API int posix_spawnattr_init(posix_spawnattr_t* attributes);
|
|
NTL_POSIX_API int posix_spawnattr_destroy(posix_spawnattr_t* attributes);
|
|
NTL_POSIX_API int posix_spawnattr_getflags(const posix_spawnattr_t* attributes, short* flags);
|
|
NTL_POSIX_API int posix_spawnattr_setflags(posix_spawnattr_t* attributes, short flags);
|
|
NTL_POSIX_API int posix_spawnattr_getpgroup(const posix_spawnattr_t* attributes, pid_t* pgroup);
|
|
NTL_POSIX_API int posix_spawnattr_setpgroup(posix_spawnattr_t* attributes, pid_t pgroup);
|
|
NTL_POSIX_API int posix_spawnattr_getsigmask(const posix_spawnattr_t* attributes, sigset_t* mask);
|
|
NTL_POSIX_API int posix_spawnattr_setsigmask(posix_spawnattr_t* attributes, const sigset_t* mask);
|
|
NTL_POSIX_API int posix_spawnattr_getsigdefault(const posix_spawnattr_t* attributes, sigset_t* set);
|
|
NTL_POSIX_API int posix_spawnattr_setsigdefault(posix_spawnattr_t* attributes, const sigset_t* set);
|
|
|
|
NTL_POSIX_API int posix_spawn(pid_t* pid, const char* path,
|
|
const posix_spawn_file_actions_t* fileActions,
|
|
const posix_spawnattr_t* attributes,
|
|
char* const argv[], char* const envp[]);
|