Fix process output truncation on POSIX

This commit is contained in:
Krzosa Karol
2026-03-19 10:33:56 +01:00
parent 7cfae9af92
commit 3c6153380d

View File

@@ -351,18 +351,15 @@ bool IsValid(Process *process) {
}
int status = 0;
pollfd p = {};
p.fd = plat->child_stdout_read;
p.events = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
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;
pid_t result = waitpid(plat->pid, &status, WNOHANG);
if (result == 0) {
return true;
}
return true;
Assert(result != -1);
process->exit_code = WIFEXITED(status) ? WEXITSTATUS(status) : -1;
process->is_valid = false;
return false;
}
void KillProcess(Process *process) {
@@ -384,7 +381,7 @@ String PollStdout(Allocator allocator, Process *process, bool force_read) {
p.events = POLLIN;
int res = poll(&p, 1, 0);
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;
}
@@ -471,10 +468,9 @@ void UpdateProcesses() {
View *view = GetView(it.args.output_view);
String poll = PollStdout(scratch, &it, false);
if (poll.len) {
if (poll.len > 0) {
Append(view, poll, it.args.scroll_to_end);
}
if (!IsValid(&it)) {
} else if (!IsValid(&it)) {
ReportConsolef("process %lld exit code = %d", it.id, it.exit_code);
remove_item = true;
}