tb Add & syntax to run commands without blocking/waiting

This commit is contained in:
2025-10-16 15:55:39 +02:00
parent e7421f73bb
commit 55f5fbefe4

View File

@ -188,6 +188,17 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
tz_classify(&tz); tz_classify(&tz);
tz_expandspecial(&tz); tz_expandspecial(&tz);
bool wait = true;
if (tz.tokens->str[0] == '&') {
Token *tk = tz.tokens;
LL_REMOVE(tz.tokens, tk);
ufree(tk->str);
ufree(tk);
wait = false;
}
Token *cmdtk = tz.tokens; Token *cmdtk = tz.tokens;
if (cmdtk->type == TOK_CMD) { if (cmdtk->type == TOK_CMD) {
ok = cmdtk->cmd(cmdtk->next); ok = cmdtk->cmd(cmdtk->next);
@ -217,15 +228,17 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
proc_run(app); proc_run(app);
while(proc_pollstate(app) != 4) { if (wait) {
if (interactive) { while(proc_pollstate(app) != 4) {
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL); if (interactive) {
if (key > 0 && (uint8_t)key == C('S')) { int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL);
proc_kill(app); if (key > 0 && (uint8_t)key == C('S')) {
goto cleanup; proc_kill(app);
goto cleanup;
}
} }
schedrelease();
} }
schedrelease();
} }
cleanup: { cleanup: {