Split processctl() syscall into multiple smaller ones
This commit is contained in:
@ -9,11 +9,11 @@ void tb_runinitscript(void) {
|
||||
devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)"termdev", 0, 0);
|
||||
|
||||
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb" };
|
||||
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)(char **)tbargs, ARRLEN(tbargs));
|
||||
int32_t tb = proc_spawn("base:/bin/tb", tbargs, ARRLEN(tbargs));
|
||||
|
||||
processctl(tb, PCTL_RUN, 0, 0, 0);
|
||||
proc_run(tb);
|
||||
|
||||
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
while(proc_pollstate(tb) != 4) {
|
||||
int32_t r;
|
||||
|
||||
char buf[100];
|
||||
@ -28,7 +28,7 @@ void tb_runinitscript(void) {
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
|
||||
PID = proc_getpid();
|
||||
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);
|
||||
devctl(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (uint8_t *)PID, 0, 0);
|
||||
|
||||
|
||||
@ -22,6 +22,6 @@ void pctl_kill(void) {
|
||||
}
|
||||
|
||||
if (PCTL_KILL_CONFIG.pid != -1) {
|
||||
processctl(PCTL_KILL_CONFIG.pid, PCTL_KILL, 0, 0, 0);
|
||||
proc_kill(PCTL_KILL_CONFIG.pid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ void pctl_ls(void) {
|
||||
|
||||
static const char *states[] = {"embryo", "ready", "zombie", "waiting", "died"};
|
||||
|
||||
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
|
||||
int32_t procslen = proc_listsize();
|
||||
|
||||
char *namebuf = umalloc(34);
|
||||
char *membuf = umalloc(20);
|
||||
@ -38,7 +38,7 @@ void pctl_ls(void) {
|
||||
string_memset(namebuf, 0, 34);
|
||||
string_memset(membuf, 0, 20);
|
||||
|
||||
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
||||
int32_t r = proc_stat(i, &stat);
|
||||
if (r == E_OK) {
|
||||
if (PCTL_LS_CONFIG.specificproc != NULL
|
||||
&& string_strcmp(stat.name, PCTL_LS_CONFIG.specificproc) != 0) {
|
||||
|
||||
@ -206,20 +206,20 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
|
||||
string_memcpy(args1[i], argtk->str, MIN(string_len(argtk->str), PROC_ARG_MAX));
|
||||
}
|
||||
|
||||
int32_t app = processctl(-1, PCTL_SPAWN, (uint64_t)cmdtk->str, (uint64_t)args1, argslen1);
|
||||
int32_t app = proc_spawn(cmdtk->str, args1, argslen1);
|
||||
if (app < 0) {
|
||||
usprintf(RES.errmsg, "Could not run %s: %s\n", cmdtk->str, ERRSTRING(app));
|
||||
ok = false;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
processctl(app, PCTL_RUN, 0, 0, 0);
|
||||
proc_run(app);
|
||||
|
||||
while(processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
while(proc_pollstate(app) != 4) {
|
||||
if (interactive) {
|
||||
int32_t key = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, (uint8_t *)PID, 0, 0);
|
||||
if (key > 0 && (uint8_t)key == C('S')) {
|
||||
processctl(app, PCTL_KILL, 0, 0, 0);
|
||||
proc_kill(app);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ void do_mode_interactive(void) {
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
PID = processctl(-1, PCTL_GETPID, 0, 0, 0);
|
||||
PID = proc_getpid();
|
||||
|
||||
set_config();
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ bool rt_do(Token *tks) {
|
||||
args1[ARRLEN(prepended_args)] = umalloc(PROC_ARG_MAX);
|
||||
string_strcpy(args1[ARRLEN(prepended_args)], s);
|
||||
|
||||
int32_t app = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)args1, ARRLEN(prepended_args)+1);
|
||||
int32_t app = proc_spawn("base:/bin/tb", args1, ARRLEN(prepended_args)+1);
|
||||
if (app < 0) {
|
||||
ok = false;
|
||||
goto done;
|
||||
@ -123,9 +123,9 @@ bool rt_do(Token *tks) {
|
||||
ipc_pipemake(10);
|
||||
ipc_pipeconnect(app, 0, PID, 10);
|
||||
|
||||
processctl(app, PCTL_RUN, 0, 0, 0);
|
||||
proc_run(app);
|
||||
|
||||
while (processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
while (proc_pollstate(app) != 4) {
|
||||
int32_t r;
|
||||
char buf[100];
|
||||
string_memset(buf, 0, sizeof(buf));
|
||||
|
||||
Reference in New Issue
Block a user