Skip to content

Commit 0053779

Browse files
committed
COMMON: fixes for RUN/EXEC
1 parent 39a3075 commit 0053779

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

src/common/system.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,16 @@ int dev_run(const char *src, var_t *r, int wait) {
122122
result = 0;
123123
}
124124
} else if (wait) {
125-
char *out = shell(src);
126-
if (out != NULL) {
127-
free(out);
125+
STARTUPINFO si;
126+
PROCESS_INFORMATION pi;
127+
memset(&si, 0, sizeof(STARTUPINFO));
128+
si.cb = sizeof(STARTUPINFO);
129+
si.dwFlags = STARTF_USESHOWWINDOW;
130+
si.wShowWindow = SW_SHOWNORMAL;
131+
if (CreateProcess(NULL, (LPSTR)cmd, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)) {
132+
WaitForSingleObject(pi.hProcess, INFINITE);
133+
CloseHandle(pi.hProcess);
134+
CloseHandle(pi.hThread);
128135
} else {
129136
result = 0;
130137
}

src/ui/system.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,13 @@ void System::setRestart() {
10331033
_state = kRestartState;
10341034
}
10351035

1036+
void System::systemLog(const char *buf) {
1037+
deviceLog("%s", buf);
1038+
int prevScreen = _output->selectBackScreen(CONSOLE_SCREEN);
1039+
_output->print(buf);
1040+
_output->selectBackScreen(prevScreen);
1041+
}
1042+
10361043
void System::systemPrint(const char *format, ...) {
10371044
va_list args;
10381045

@@ -1046,12 +1053,7 @@ void System::systemPrint(const char *format, ...) {
10461053
vsnprintf(buf, size + 1, format, args);
10471054
va_end(args);
10481055
buf[size] = '\0';
1049-
1050-
deviceLog("%s", buf);
1051-
1052-
int prevScreen = _output->selectBackScreen(CONSOLE_SCREEN);
1053-
_output->print(buf);
1054-
_output->selectBackScreen(prevScreen);
1056+
systemLog(buf);
10551057
free(buf);
10561058
}
10571059
}
@@ -1158,7 +1160,7 @@ void osd_write(const char *str) {
11581160

11591161
void lwrite(const char *str) {
11601162
if (!(str[0] == '\n' && str[1] == '\0') && !g_system->isClosing()) {
1161-
g_system->systemPrint(str);
1163+
g_system->systemLog(str);
11621164
}
11631165
}
11641166

src/ui/system.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct System {
4949
void setLoadBreak(const char *path);
5050
void setLoadPath(const char *path);
5151
void setRunning(bool running);
52+
void systemLog(const char *msg);
5253
void systemPrint(const char *msg, ...);
5354
AnsiWidget *getOutput() { return _output; }
5455

0 commit comments

Comments
 (0)