ulib uprintf to pipe not termdev, ulib Add stringbuffer and linearlist, tb Capture subshell output

This commit is contained in:
2025-10-01 20:08:44 +02:00
parent 0e4a35eb86
commit 62cf07afc7
11 changed files with 210 additions and 13 deletions

View File

@ -3,15 +3,27 @@
uint64_t PID;
Dev_t ps2kbdev;
Dev_t termdev;
void tb_runinitscript(void) {
devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)DEV_TERMDEV, 0, 0);
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb", "-logcmds", "yes" };
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)&tbargs, ARRLEN(tbargs));
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)(char **)tbargs, ARRLEN(tbargs));
processctl(tb, PCTL_RUN, 0, 0, 0);
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
int32_t r = devctl(&ps2kbdev, 0x00, NULL, 0, 0);
int32_t r;
char buf[100];
string_memset(buf, 0, sizeof(buf));
r = ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_READ, (uint8_t *)buf, sizeof(buf)-1);
if (r > 0) {
devctl(&termdev, 0x00, (uint8_t *)buf, string_len(buf), 0);
}
r = devctl(&ps2kbdev, 0x00, NULL, 0, 0);
if (r != E_NOTYET) {
uint8_t b = r;
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_WRITE, &b, 1);