Fix process polling exit code
This commit is contained in:
@@ -356,7 +356,6 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
process.is_valid = true;
|
|
||||||
plat->child_stdout_read = stdout_desc[PIPE_READ];
|
plat->child_stdout_read = stdout_desc[PIPE_READ];
|
||||||
plat->stdin_write = stdin_desc[PIPE_WRITE];
|
plat->stdin_write = stdin_desc[PIPE_WRITE];
|
||||||
|
|
||||||
@@ -365,8 +364,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
|
|||||||
CloseStdin(&process);
|
CloseStdin(&process);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.is_valid = true;
|
||||||
|
|
||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,12 +375,14 @@ bool IsValid(Process *process) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
pid_t result = waitpid(plat->pid, &status, WNOHANG);
|
pollfd p = {};
|
||||||
if (result >= 0) {
|
p.fd = plat->child_stdout_read;
|
||||||
if (WIFSIGNALED(status) || WIFEXITED(status)) {
|
p.events = POLLRDHUP | POLLERR | POLLHUP | POLLNVAL;
|
||||||
process->exit_code = WEXITSTATUS(status);
|
int res = poll(&p, 1, 0);
|
||||||
return false;
|
if (res > 0) {
|
||||||
}
|
pid_t result = waitpid(plat->pid, &status, 0);
|
||||||
|
process->exit_code = WEXITSTATUS(status);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -406,7 +406,7 @@ String PollStdout(Allocator allocator, Process *process, bool force_read) {
|
|||||||
p.fd = plat->child_stdout_read;
|
p.fd = plat->child_stdout_read;
|
||||||
p.events = POLLIN;
|
p.events = POLLIN;
|
||||||
int res = poll(&p, 1, 0);
|
int res = poll(&p, 1, 0);
|
||||||
if (res == 1 || 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, 4 * 4096);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -458,16 +458,16 @@ function OnSave(buffer_id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function IsCodeExclude(s, meta)
|
function IsCodeExclude(s, meta)
|
||||||
if s:match("/.git$") or s:match("\\.git$") or
|
if s:match("/%.git$") or s:match("\\%.git$") or
|
||||||
s:match(".exe$") or
|
s:match("%.exe$") or
|
||||||
s:match(".bin$") or
|
s:match("%.bin$") or
|
||||||
s:match(".obj$") or
|
s:match("%.obj$") or
|
||||||
s:match(".o$") or
|
s:match("%.o$") or
|
||||||
s:match(".lib$") or
|
s:match("%.lib$") or
|
||||||
s:match(".ilk$") or
|
s:match("%.ilk$") or
|
||||||
s:match(".cache$") or
|
s:match("%.cache$") or
|
||||||
s:match(".exp$") or
|
s:match("%.exp$") or
|
||||||
s:match(".pdb$") or
|
s:match("%.pdb$") or
|
||||||
s:match("/external/") or s:match("\\external\\")
|
s:match("/external/") or s:match("\\external\\")
|
||||||
then
|
then
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -16,9 +16,6 @@ struct UnixProcess {
|
|||||||
// the appropriate handles. This happens in this case when git grep calls
|
// the appropriate handles. This happens in this case when git grep calls
|
||||||
// 'less' program which errors out and doesn't print anything
|
// 'less' program which errors out and doesn't print anything
|
||||||
// @todo: maybe I should ask someone smarter about this!
|
// @todo: maybe I should ask someone smarter about this!
|
||||||
|
|
||||||
|
|
||||||
// @todo: rework to fit both linux and windows!
|
|
||||||
void UpdateProcesses() {
|
void UpdateProcesses() {
|
||||||
IterRemove(ActiveProcesses) {
|
IterRemove(ActiveProcesses) {
|
||||||
IterRemovePrepare(ActiveProcesses);
|
IterRemovePrepare(ActiveProcesses);
|
||||||
@@ -30,16 +27,6 @@ void UpdateProcesses() {
|
|||||||
Command_Append(view, poll, it.scroll_to_end);
|
Command_Append(view, poll, it.scroll_to_end);
|
||||||
}
|
}
|
||||||
if (!IsValid(&it)) {
|
if (!IsValid(&it)) {
|
||||||
for (;;) {
|
|
||||||
String poll = PollStdout(scratch, &it, true);
|
|
||||||
if (poll.len) {
|
|
||||||
Command_Append(view, poll, it.scroll_to_end);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
printf("exit code = %d\n", it.exit_code);
|
printf("exit code = %d\n", it.exit_code);
|
||||||
remove_item = true;
|
remove_item = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user