Proc
Description
Opaque platform-dependent handle storing process information.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Proc.c:12:
#define _DEFAULT_SOURCE
#include <Misra/Sys/Proc.h>
#include <Misra/Sys.h>
#include <Misra/Std/Memory.h>- In
Proc.c:48:
#endif
struct Proc {
int exit_code;
bool completed;- In
Proc.c:62:
HANDLE hStderrRead;
#else
# error "Unsupported OS for Proc"
#endif
};- In
Proc.c:69:
#define WRITE_END 1
Proc *ProcCreate(const char *filepath, char **argv, char **envp, Allocator *alloc) {
if (!alloc) {
LOG_FATAL("ProcCreate requires an allocator");- In
Proc.c:147:
close(stderr_pipe[WRITE_END]);
Proc *proc = (Proc *)AllocatorAlloc(alloc, sizeof(Proc), true);
if (!proc) {- In
Proc.c:229:
CloseHandle(hStderrWrite); // parent won't write to child's stderr, will read from it
Proc *proc = (Proc *)AllocatorAlloc(alloc, sizeof(Proc), true);
if (!proc) {- In
Proc.c:249:
}
ProcStatus ProcWait(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:293:
}
ProcStatus ProcWaitFor(Proc *proc, u64 timeout_ms) {
if (!proc) {
LOG_FATAL("Invalid arguments");- In
Proc.c:364:
}
void ProcTerminate(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:419:
void ProcDestroy(Proc *proc, Allocator *alloc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:438:
CloseHandle(proc->pi.hProcess);
#endif
AllocatorFree(alloc, proc, sizeof(Proc));
}- In
Proc.c:441:
}
i32 ProcWriteToStdin(Proc *proc, Str *buf) {
if (!proc || !buf) {
LOG_FATAL("Invalid arguments");- In
Proc.c:456:
}
i32 sys_proc_read_internal(Proc *proc, Str *buf, bool is_stdout) {
if (!proc || !buf) {
LOG_FATAL("Invalid argument");- In
Proc.c:540:
}
i32 ProcReadFromStdout(Proc *proc, Str *buf) {
return sys_proc_read_internal(proc, buf, /* is stdout*/ true);
}- In
Proc.c:544:
}
i32 ProcReadFromStderr(Proc *proc, Str *buf) {
return sys_proc_read_internal(proc, buf, /* is stdout*/ false);
}- In
Proc.c:548:
}
i32 ProcGetId(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:560:
}
i32 ProcIsRunning(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Proc.c:584:
}
i32 ProcGetExitCode(Proc *proc) {
if (!proc) {
LOG_FATAL("Invalid argument");- In
Sys.h:27:
#if MISRA_HAVE_SYS_PROC
# include <Misra/Sys/Proc.h>
#endif- In
Proc.h:41:
/// FAILURE: NULL.
///
Proc *ProcCreate(const char *path, char **argv, char **envp, Allocator *alloc);
///
- In
Proc.h:51:
/// `SYS_PROC_STATUS_ERROR`.
///
ProcStatus ProcWait(Proc *proc);
///
- In
Proc.h:64:
/// waiting fails.
///
ProcStatus ProcWaitFor(Proc *proc, u64 timeout);
///
- In
Proc.h:74:
/// FAILURE: Abort with log message.
///
void ProcTerminate(Proc *proc);
///
- In
Proc.h:86:
/// FAILURE: Abort with log message.
///
void ProcDestroy(Proc *proc, Allocator *alloc);
///
- In
Proc.h:97:
/// FAILURE: Return -1
///
i32 ProcWriteToStdin(Proc *proc, Str *buf);
///
- In
Proc.h:105:
/// FAILURE: Abort with a log message.
///
i32 ProcGetExitCode(Proc *proc);
///
- In
Proc.h:116:
/// FAILURE: Return -1
///
i32 ProcReadFromStdout(Proc *proc, Str *buf);
///
- In
Proc.h:127:
/// FAILURE: Return -1
///
i32 ProcReadFromStderr(Proc *proc, Str *buf);
///
- In
Proc.h:137:
/// FAILURE: Returns -1
///
i32 ProcGetId(Proc *proc);
///
- In
Proc.h:144:
/// proc[in] : Child process handle.
///
ProcStatus ProcGetStatus(Proc *proc);
///
- In
SubProcComm.c:14:
// create a new child process
Proc *proc = ProcCreate(argv[1], argv + 1, envp, &alloc.base);
// write something to it's stdout
- In
ElfInfo.c:145:
ELF_MACHINE_XTENSA = 94, /// Tensilica Xtensa Architecture
ELF_MACHINE_VIDEOCORE = 95, /// Alphamosaic VideoCore
ELF_MACHINE_TMM_GPP = 96, /// Thompson Multimedia General Purpose Proc
ELF_MACHINE_NS32K = 97, /// National Semi. 32000
ELF_MACHINE_TPC = 98, /// Tenor Network TPC
Last updated on