Fix stream life-time race condition by reversing ownership
All checks were successful
Build ISO image / build-and-deploy (push) Successful in 1m28s
Build documentation / build-and-deploy (push) Successful in 43s

This commit is contained in:
2026-04-30 17:25:21 +02:00
parent 77fa271cca
commit 6a0aeea88a
10 changed files with 52 additions and 36 deletions

View File

@@ -46,7 +46,7 @@ void in_stream_read_line(const char* prompt, char* buffer, size_t max) {
for (;;) {
uint8_t ch;
if (stream_read(process_get_pgid(), STREAM_IN, &ch, 1) <= 0) {
if (stream_read(STREAM_IN, &ch, 1) <= 0) {
sched();
continue;
}

View File

@@ -1,3 +1,4 @@
#include <debugconsole.h>
#include <mprintf.h>
#include <printf.h>
#include <process.h>
@@ -32,7 +33,7 @@ void mprintf(const char* fmt, ...) {
va_end(args);
stream_write(process_get_pgid(), STREAM_OUT, mprintf_buffer, len);
stream_write(process_get_exec_pgid(), STREAM_OUT, mprintf_buffer, len);
mprintf_buffer_unlock();
}

View File

@@ -101,8 +101,8 @@ int stream_write(int pgid, int rid, void* buffer, size_t size) {
return (int)do_syscall(SYS_STREAM_WRITE, pgid, rid, buffer, size);
}
int stream_read(int pgid, int rid, void* buffer, size_t size) {
return (int)do_syscall(SYS_STREAM_READ, pgid, rid, buffer, size);
int stream_read(int rid, void* buffer, size_t size) {
return (int)do_syscall(SYS_STREAM_READ, rid, buffer, size);
}
int get_proc_info(struct proc_info* infos, size_t count) {
@@ -122,3 +122,5 @@ int volume_delete(const char* key) { return (int)do_syscall(SYS_VOLUME_DELETE, k
int date_time(struct date_time* dt) { return (int)do_syscall(SYS_DATE_TIME, dt); }
const char* get_cmdline(void) { return (const char*)do_syscall(SYS_GET_CMDLINE, 0); }
int proc_is_alive(int pid) { return (int)do_syscall(SYS_PROC_IS_ALIVE, pid); }

View File

@@ -110,7 +110,7 @@ int get_self_pid(void);
int stream_write(int pgid, int rid, void* buffer, size_t size);
/* Read from a stream */
int stream_read(int pgid, int rid, void* buffer, size_t size);
int stream_read(int rid, void* buffer, size_t size);
/* get process information */
int get_proc_info(struct proc_info* infos, size_t count);
@@ -130,4 +130,7 @@ int date_time(struct date_time* dt);
/* Get commandline string */
const char* get_cmdline(void);
/* check if PID is alive */
int proc_is_alive(int pid);
#endif // _LIBMSL_M_SYSTEM_H