tb Allow the user to kill current process in interactive mode (Ctrl+S)
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
#include <ulib.h>
|
||||
#include "interp.h"
|
||||
#include "runtime.h"
|
||||
#include "macros.h"
|
||||
|
||||
extern uint64_t PID;
|
||||
|
||||
@ -161,7 +162,7 @@ bool interp_readline(char *data, const char **bgptr, const char **endptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
|
||||
bool interp_runstring(const char *string, InterpResult **res, bool logcmds, bool interactive) {
|
||||
*res = &RES;
|
||||
string_memset(RES.errmsg, 0, sizeof(RES.errmsg));
|
||||
|
||||
@ -230,16 +231,25 @@ bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
|
||||
|
||||
processctl(app, PCTL_RUN, 0, 0, 0);
|
||||
|
||||
uint8_t b;
|
||||
while(processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||
if (interactive) {
|
||||
int32_t nrd = ipcpipe(PID, IPCPIPE_IN, IPCPIPE_READ, &b, 1);
|
||||
if (nrd > 0 && b == C('S')) {
|
||||
processctl(app, PCTL_KILL, 0, 0, 0);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
schedrelease();
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cleanup: {
|
||||
for (size_t j = 0; j < argslen1; j++) {
|
||||
dlfree(args1[j]);
|
||||
}
|
||||
dlfree(args1);
|
||||
dlfree(appname);
|
||||
}
|
||||
}
|
||||
|
||||
tz_free(&tz);
|
||||
|
Reference in New Issue
Block a user