Fix stream life-time race condition by reversing ownership
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user