Files
mop3/init/init.c
kamkow1 4c26fcfc11
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m30s
CE & init use new streams IPC
2026-03-18 22:40:11 +01:00

48 lines
828 B
C

#include <debugconsole.h>
#include <kb.h>
#include <limits.h>
#include <malloc.h>
#include <process.h>
#include <stddef.h>
#include <stdint.h>
#include <streams.h>
#include <string.h>
#include <terminal.h>
#define RECV_MAX (1024 * 16)
static int ce_pgid;
void receiver (void* arg) {
(void)arg;
char recv[RECV_MAX];
int n;
for (;;) {
n = stream_read (ce_pgid, STREAM_OUT, (void*)recv, RECV_MAX - 1);
if (n > 0)
terminal_print (recv, n);
else
sched ();
}
}
void app_main (void) {
debug_printf ("Init process is running. Starting user shell...\n");
int ce_pid = exec ("sys", "/ce");
ce_pgid = get_procgroup (ce_pid);
process_spawn (&receiver, NULL);
for (;;) {
int ch = kb_read_key ();
if (ch == 0)
continue;
stream_write (ce_pgid, STREAM_IN, &ch, 1);
}
}