Fix process output truncation on POSIX
This commit is contained in:
@@ -350,19 +350,16 @@ bool IsValid(Process *process) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
pollfd p = {};
|
pid_t result = waitpid(plat->pid, &status, WNOHANG);
|
||||||
p.fd = plat->child_stdout_read;
|
if (result == 0) {
|
||||||
p.events = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
|
return true;
|
||||||
int res = poll(&p, 1, 0);
|
|
||||||
if (res > 0) {
|
|
||||||
pid_t result = waitpid(plat->pid, &status, 0);
|
|
||||||
Assert(result != -1);
|
|
||||||
process->exit_code = WEXITSTATUS(status);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
Assert(result != -1);
|
||||||
|
process->exit_code = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
|
||||||
|
process->is_valid = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KillProcess(Process *process) {
|
void KillProcess(Process *process) {
|
||||||
@@ -384,7 +381,7 @@ String PollStdout(Allocator allocator, Process *process, bool force_read) {
|
|||||||
p.events = POLLIN;
|
p.events = POLLIN;
|
||||||
int res = poll(&p, 1, 0);
|
int res = poll(&p, 1, 0);
|
||||||
if (res > 0 || force_read) {
|
if (res > 0 || force_read) {
|
||||||
result.len = read(plat->child_stdout_read, result.data, 4 * 4096);
|
result.len = read(plat->child_stdout_read, result.data, 16 * 4096);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -471,10 +468,9 @@ void UpdateProcesses() {
|
|||||||
View *view = GetView(it.args.output_view);
|
View *view = GetView(it.args.output_view);
|
||||||
|
|
||||||
String poll = PollStdout(scratch, &it, false);
|
String poll = PollStdout(scratch, &it, false);
|
||||||
if (poll.len) {
|
if (poll.len > 0) {
|
||||||
Append(view, poll, it.args.scroll_to_end);
|
Append(view, poll, it.args.scroll_to_end);
|
||||||
}
|
} else if (!IsValid(&it)) {
|
||||||
if (!IsValid(&it)) {
|
|
||||||
ReportConsolef("process %lld exit code = %d", it.id, it.exit_code);
|
ReportConsolef("process %lld exit code = %d", it.id, it.exit_code);
|
||||||
remove_item = true;
|
remove_item = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user