Proc
Description
Process handle. Layout is platform-conditional. Stack-declare with ProcInit(path, argv, envp); don’t poke fields directly. The _pid (POSIX) or _pi.hProcess (Windows) being zero / NULL means the init failed – check with ProcOk(&p).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Sys.h:28:
#if FEATURE_SYS_PROC
# include <Misra/Sys/Proc.h>
#endif- In
Proc.h:78:
int _stderr_fd; // read here from child error output
#endif
} Proc;
///
- In
Proc.h:98:
/// TAGS: Sys, Proc, Spawn
///
Proc proc_init(Zstr path, char **argv, char **envp, Allocator *alloc);
#define ProcInit(...) OVERLOAD(ProcInit, __VA_ARGS__)- In
Proc.h:117:
/// TAGS: Sys, Proc, Deinit
///
void ProcDeinit(Proc *p);
///
- In
Proc.h:129:
/// TAGS: Proc, Query, State
///
static inline bool ProcOk(const Proc *p) {
if (!p) {
return false;- In
Proc.h:150:
/// TAGS: Proc, Wait, API
///
ProcStatus ProcWait(Proc *proc);
///
- In
Proc.h:163:
/// TAGS: Proc, Wait, Timeout
///
ProcStatus ProcWaitFor(Proc *proc, u64 timeout_ms);
///
- In
Proc.h:178:
/// TAGS: Proc, Terminate, API
///
void ProcTerminate(Proc *proc);
///
- In
Proc.h:188:
/// TAGS: Proc, Write, Stdio
///
i32 ProcWriteToStdin(Proc *proc, const Str *buf);
///
- In
Proc.h:200:
/// TAGS: Proc, Get, ExitCode
///
i32 ProcGetExitCode(Proc *proc);
///
- In
Proc.h:213:
/// TAGS: Proc, Read, Stdio
///
i32 ProcReadFromStdout(Proc *proc, Str *buf);
///
- In
Proc.h:226:
/// TAGS: Proc, Read, Stdio
///
i32 ProcReadFromStderr(Proc *proc, Str *buf);
///
- In
Proc.h:236:
/// TAGS: Proc, Get, Identity
///
i32 ProcGetId(Proc *proc);
///
- In
Proc.h:250:
/// TAGS: Proc, Get, Status
///
ProcStatus ProcGetStatus(Proc *proc);
///
- In
Proc.c:7:
/// System functions for cross-platform process creation and interaction
#include <Misra/Sys/Proc.h>
#include <Misra/Std/Log.h>
#include <Misra/Std/Memory.h>- In
Proc.c:109:
#define WRITE_END 1
Proc proc_init(Zstr filepath, char **argv, char **envp, Allocator *alloc) {
Proc proc = {0};
#if PLATFORM_UNIX- In
Proc.c:110:
Proc proc_init(Zstr filepath, char **argv, char **envp, Allocator *alloc) {
Proc proc = {0};
#if PLATFORM_UNIX
(void)alloc; // POSIX path doesn't need an allocator
- In
Proc.c:265:
}
ProcStatus ProcWait(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:312:
}
ProcStatus ProcWaitFor(Proc *proc, u64 timeout_ms) {
if (!proc) {
LOG_FATAL("Invalid arguments");- In
Proc.c:386:
}
void ProcTerminate(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:442:
}
void ProcDeinit(Proc *proc) {
if (!proc) {
return;- In
Proc.c:465:
}
i32 ProcWriteToStdin(Proc *proc, const Str *buf) {
if (!proc || !buf) {
LOG_FATAL("Invalid arguments");- In
Proc.c:480:
}
static i32 proc_read_internal(Proc *proc, Str *buf, bool is_stdout) {
if (!proc || !buf) {
LOG_FATAL("Invalid argument");- In
Proc.c:559:
}
i32 ProcReadFromStdout(Proc *proc, Str *buf) {
return proc_read_internal(proc, buf, /* is stdout*/ true);
}- In
Proc.c:563:
}
i32 ProcReadFromStderr(Proc *proc, Str *buf) {
return proc_read_internal(proc, buf, /* is stdout*/ false);
}- In
Proc.c:567:
}
i32 ProcGetId(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:579:
}
ProcStatus ProcGetStatus(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:618:
}
i32 ProcGetExitCode(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");
Last updated on