MOS Source Code
Loading...
Searching...
No Matches
process.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include "mos/io/io.h"
6
8
9#define PROCESS_MAGIC_PROC MOS_FOURCC('P', 'R', 'O', 'C')
10
11typedef struct _hashmap hashmap_t;
12
16typedef struct
17{
18 io_t *in, *out, *err;
19} stdio_t;
20
22
24{
25 return process != NULL && process->magic == PROCESS_MAGIC_PROC;
26}
27
29{
30 return (stdio_t){
31 .in = current_process->files[0].io,
32 .out = current_process->files[1].io,
33 .err = current_process->files[2].io,
34 };
35}
36
37process_t *process_allocate(process_t *parent, const char *name);
38void process_destroy(process_t *process);
39
40process_t *process_new(process_t *parent, const char *name, const stdio_t *ios);
42
43fd_t process_attach_ref_fd(process_t *process, io_t *file, fd_flags_t flags);
44io_t *process_get_fd(process_t *process, fd_t fd);
45bool process_detach_fd(process_t *process, fd_t fd);
46
47pid_t process_wait_for_pid(pid_t pid, u32 *exit_code, u32 flags);
48
49[[noreturn]] void process_exit(process_t *process, u8 exit_code, signal_t signal);
50
51void process_dump_mmaps(const process_t *process);
52
53bool process_register_signal_handler(process_t *process, signal_t sig, const sigaction_t *sigaction);
54
56long process_do_execveat(process_t *process, fd_t dirfd, const char *path, const char *const argv[], const char *const envp[], int flags);
fd_flags_t
Definition fs_types.h:47
const char ** argv
Definition kmain.c:44
#define should_inline
Definition mos_global.h:37
#define NULL
Definition pb_syshdr.h:46
#define current_process
Definition platform.h:31
fd_t process_attach_ref_fd(process_t *process, io_t *file, fd_flags_t flags)
Definition process.c:171
should_inline bool process_is_valid(const process_t *process)
Definition process.h:23
pid_t process_wait_for_pid(pid_t pid, u32 *exit_code, u32 flags)
Definition process.c:215
bool process_register_signal_handler(process_t *process, signal_t sig, const sigaction_t *sigaction)
Definition process.c:380
void process_destroy(process_t *process)
Definition process.c:107
long process_do_execveat(process_t *process, fd_t dirfd, const char *path, const char *const argv[], const char *const envp[], int flags)
Definition execve.c:18
void process_dump_mmaps(const process_t *process)
Definition process.c:365
hashmap_t process_table
Definition process.c:34
process_t * process_get(pid_t pid)
Definition process.c:162
should_inline stdio_t current_stdio(void)
Definition process.h:28
void process_exit(process_t *process, u8 exit_code, signal_t signal)
Definition process.c:281
io_t * process_get_fd(process_t *process, fd_t fd)
Definition process.c:192
process_t * process_allocate(process_t *parent, const char *name)
Definition process.c:55
#define PROCESS_MAGIC_PROC
Definition process.h:9
process_t * process_new(process_t *parent, const char *name, const stdio_t *ios)
Definition process.c:143
process_t * process_do_fork(process_t *process)
Definition fork.c:26
bool process_detach_fd(process_t *process, fd_t fd)
Definition process.c:200
int signal_t
Definition signal_types.h:9
const char * name
Definition slab.c:31
Definition io.h:46
A wrapper type for the standard I/O streams.
Definition process.h:17
io_t * err
Definition process.h:18
unsigned int u32
Definition types.h:21
s32 fd_t
Definition types.h:81
s32 pid_t
Definition types.h:78
unsigned char u8
Definition types.h:19