This commit is contained in:
2026-04-17 17:28:49 +08:00
parent f93af4a2a6
commit 42b5925222
11 changed files with 699 additions and 50 deletions

View File

@@ -52,7 +52,9 @@ static int ush_fg_pick_latest_job(u64 *out_pid) {
continue;
}
if (snap.state != CLEONOS_PROC_STATE_PENDING && snap.state != CLEONOS_PROC_STATE_RUNNING) {
if (snap.state != CLEONOS_PROC_STATE_PENDING &&
snap.state != CLEONOS_PROC_STATE_RUNNING &&
snap.state != CLEONOS_PROC_STATE_STOPPED) {
continue;
}
@@ -99,6 +101,7 @@ static int ush_fg_wait_pid(u64 pid) {
static int ush_cmd_fg(const char *arg) {
u64 pid = 0ULL;
cleonos_proc_snapshot snap;
if (arg != (const char *)0 && arg[0] != '\0') {
if (ush_parse_u64_dec(arg, &pid) == 0 || pid == 0ULL) {
@@ -112,6 +115,25 @@ static int ush_cmd_fg(const char *arg) {
}
}
if (cleonos_sys_proc_snapshot(pid, &snap, (u64)sizeof(snap)) == 0ULL) {
ush_writeln("fg: pid not found");
return 0;
}
if (snap.state == CLEONOS_PROC_STATE_STOPPED) {
u64 ret = cleonos_sys_proc_kill(pid, CLEONOS_SIGCONT);
if (ret == (u64)-1) {
ush_writeln("fg: pid not found");
return 0;
}
if (ret == 0ULL) {
ush_writeln("fg: failed to continue job");
return 0;
}
}
ush_write("fg: waiting [");
ush_write_hex_u64(pid);
ush_writeln("]");