diff --git a/src/basic/unix.cpp b/src/basic/unix.cpp index 5817748..7a71347 100644 --- a/src/basic/unix.cpp +++ b/src/basic/unix.cpp @@ -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->stdin_write = stdin_desc[PIPE_WRITE]; @@ -365,8 +364,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin CloseStdin(&process); } - - + process.is_valid = true; return process; } @@ -377,12 +375,14 @@ bool IsValid(Process *process) { } int status = 0; - pid_t result = waitpid(plat->pid, &status, WNOHANG); - if (result >= 0) { - if (WIFSIGNALED(status) || WIFEXITED(status)) { - process->exit_code = WEXITSTATUS(status); - return false; - } + 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); + process->exit_code = WEXITSTATUS(status); + return false; } return true; @@ -406,7 +406,7 @@ String PollStdout(Allocator allocator, Process *process, bool force_read) { p.fd = plat->child_stdout_read; p.events = POLLIN; 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); } return result; diff --git a/src/text_editor/generated.cpp b/src/text_editor/generated.cpp index f634b7a..cb321cd 100644 --- a/src/text_editor/generated.cpp +++ b/src/text_editor/generated.cpp @@ -458,16 +458,16 @@ function OnSave(buffer_id) end function IsCodeExclude(s, meta) - if s:match("/.git$") or s:match("\\.git$") or - s:match(".exe$") or - s:match(".bin$") or - s:match(".obj$") or - s:match(".o$") or - s:match(".lib$") or - s:match(".ilk$") or - s:match(".cache$") or - s:match(".exp$") or - s:match(".pdb$") or + if s:match("/%.git$") or s:match("\\%.git$") or + s:match("%.exe$") or + s:match("%.bin$") or + s:match("%.obj$") or + s:match("%.o$") or + s:match("%.lib$") or + s:match("%.ilk$") or + s:match("%.cache$") or + s:match("%.exp$") or + s:match("%.pdb$") or s:match("/external/") or s:match("\\external\\") then return false diff --git a/src/text_editor/process.cpp b/src/text_editor/process.cpp index 5252630..ee5da83 100644 --- a/src/text_editor/process.cpp +++ b/src/text_editor/process.cpp @@ -16,9 +16,6 @@ struct UnixProcess { // the appropriate handles. This happens in this case when git grep calls // 'less' program which errors out and doesn't print anything // @todo: maybe I should ask someone smarter about this! - - -// @todo: rework to fit both linux and windows! void UpdateProcesses() { IterRemove(ActiveProcesses) { IterRemovePrepare(ActiveProcesses); @@ -30,16 +27,6 @@ void UpdateProcesses() { Command_Append(view, poll, it.scroll_to_end); } 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); remove_item = true; }