Move e_pid and e_pgid to libprocess, Add get_self_pid () syscall
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m13s

This commit is contained in:
2026-03-17 22:13:01 +01:00
parent 090a4e46ea
commit 7bcd40151d
14 changed files with 69 additions and 26 deletions

View File

@@ -3,13 +3,14 @@
#include "gapbuffer.h"
#include "interp.h"
#include "mprintf.h"
#include "self.h"
#include "strbuf.h"
#include <arena.h>
#include <debugconsole.h>
#include <kb.h>
#include <list.h>
#include <malloc.h>
#include <printf.h>
#include <process_self.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@@ -63,8 +64,7 @@ static void exec_line (const char* line) {
}
void app_main (void) {
e_pid = get_exec_pid ();
e_pgid = get_procgroup (e_pid);
libprocess_self_init ();
struct edit_line edit_line;

View File

@@ -2,7 +2,6 @@
#include "arena_alloc.h"
#include "gapbuffer.h"
#include "mprintf.h"
#include "self.h"
#include "walloc.h"
#include <arena.h>
#include <filewriter.h>
@@ -11,6 +10,7 @@
#include <malloc.h>
#include <path.h>
#include <printf.h>
#include <process_self.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@@ -231,7 +231,7 @@ void edit_start (const char* volume, const char* file_path, const char* text, si
(int)(editor.cursor.line - editor.row_offset) + 1,
(int)(editor.cursor.col - editor.col_offset) + 1 + (int)gutter_width);
mail_send (e_pgid, backbuffer, bbptr - backbuffer);
mail_send (process_get_exec_pgid (), backbuffer, bbptr - backbuffer);
uint8_t ch = 0;
mail_receive (&ch, 1);

View File

@@ -4,7 +4,6 @@
#include "edit.h"
#include "mprintf.h"
#include "parser.h"
#include "self.h"
#include <debugconsole.h>
#include <desc.h>
#include <filereader.h>
@@ -16,6 +15,7 @@
#include <path.h>
#include <printf.h>
#include <process.h>
#include <process_self.h>
#include <stddef.h>
#include <str_status.h>
#include <string.h>
@@ -160,7 +160,7 @@ static void cat (struct context* context, char** file_paths, size_t files_count)
return;
}
mail_send (e_pgid, buffer, chunk_size);
mail_send (process_get_exec_pgid (), buffer, chunk_size);
}
if (rem > 0) {
@@ -170,7 +170,7 @@ static void cat (struct context* context, char** file_paths, size_t files_count)
return;
}
mail_send (e_pgid, buffer, rem);
mail_send (process_get_exec_pgid (), buffer, rem);
}
filereader_fini (&fr);
@@ -357,7 +357,7 @@ static void cmd_collect_proc (void* arg) {
char recv[RECV_MAX];
memset (recv, 0, sizeof (recv));
if (mail_receive_nonblock (&recv, sizeof (recv) - 1) == ST_OK) {
mail_send (e_pgid, recv, strlen (recv));
mail_send (process_get_exec_pgid (), recv, strlen (recv));
}
}
}

View File

@@ -1,7 +1,7 @@
#include "mprintf.h"
#include "self.h"
#include <malloc.h>
#include <printf.h>
#include <process_self.h>
#include <stdarg.h>
#include <string.h>
#include <system.h>
@@ -22,6 +22,6 @@ void mprintf (const char* fmt, ...) {
va_end (args);
mail_send (e_pgid, buf, len);
mail_send (process_get_exec_pgid (), buf, len);
free (buf);
}

View File

@@ -1,4 +0,0 @@
#include "self.h"
int e_pid;
int e_pgid;

View File

@@ -1,7 +0,0 @@
#ifndef _SELF_H
#define _SELF_H
extern int e_pid;
extern int e_pgid;
#endif // _SELF_H

View File

@@ -5,7 +5,6 @@ c += ce.c \
parser.c \
interp.c \
mprintf.c \
self.c \
gapbuffer.c \
edit.c
@@ -16,6 +15,5 @@ o += ce.o \
parser.o \
interp.o \
mprintf.o \
self.o \
gapbuffer.o \
edit.o