tb running cmds in interactive mode
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
#include <sysdefs/processctl.h>
|
||||
#include <sysdefs/ipcpipe.h>
|
||||
#include <uprintf.h>
|
||||
#include <errors.h>
|
||||
#include "interp.h"
|
||||
#include "runtime.h"
|
||||
|
||||
@ -215,8 +216,20 @@ bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
|
||||
ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_MAKE, NULL, 0);
|
||||
|
||||
int32_t app = processctl(-1, PCTL_SPAWN, (uint64_t)(char *)appname, (uint64_t)args1, argslen1);
|
||||
if (app < 0) {
|
||||
usprintf(RES.errmsg, "Could not run %s: %s\n", appname, ERRSTRING(app));
|
||||
ok = false;
|
||||
dlfree(outbuf);
|
||||
for (size_t j = 0; j < argslen1; j++) {
|
||||
dlfree(args1[j]);
|
||||
}
|
||||
dlfree(args1);
|
||||
dlfree(appname);
|
||||
goto done;
|
||||
}
|
||||
|
||||
ipcpipe(app, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)PID, SUBPROC_PIPE_OUT);
|
||||
ipcpipe(app, IPCPIPE_IN, IPCPIPE_READ, (uint8_t *)PID, IPCPIPE_IN);
|
||||
ipcpipe(app, IPCPIPE_IN, IPCPIPE_REPLACE, (uint8_t *)PID, IPCPIPE_IN);
|
||||
processctl(app, PCTL_RUN, 0, 0, 0);
|
||||
|
||||
while (processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
@ -228,12 +241,10 @@ bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
|
||||
}
|
||||
|
||||
dlfree(outbuf);
|
||||
|
||||
for (size_t j = 0; j < argslen1; j++) {
|
||||
dlfree(args1[j]);
|
||||
}
|
||||
dlfree(args1);
|
||||
|
||||
dlfree(appname);
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,10 @@ void do_mode_interactive(void) {
|
||||
string_memset(linebuf, 0, LINEBUF_MAX);
|
||||
char c = 0;
|
||||
while (c != '\n') {
|
||||
int32_t rd = ipcpipe(IPCPIPE_SELFPID, IPCPIPE_IN, IPCPIPE_READ, (uint8_t *)&c, 1);
|
||||
int32_t rd = ipcpipe(PID, IPCPIPE_IN, IPCPIPE_READ, (uint8_t *)&c, 1);
|
||||
if (rd > 0 && cursor < LINEBUF_MAX) {
|
||||
linebuf[cursor++] = c;
|
||||
uprintf("%c", c);
|
||||
}
|
||||
}
|
||||
linebuf[cursor - 1] = '\0';
|
||||
|
Reference in New Issue
Block a user