Read as much as possible data from shell processes on each read event
We were reading at most 1024 bytes every time, going back to the event loop.
This commit is contained in:
parent
75986911f8
commit
8a74ef9804
|
@ -161,6 +161,8 @@ std::pair<String, int> ShellManager::eval(
|
|||
: FDWatcher(pipe.read_fd(), FdEvents::Read,
|
||||
[&contents, &pipe](FDWatcher& watcher, FdEvents, EventMode) {
|
||||
char buffer[1024];
|
||||
while (fd_readable(pipe.read_fd()))
|
||||
{
|
||||
size_t size = ::read(pipe.read_fd(), buffer, 1024);
|
||||
if (size <= 0)
|
||||
{
|
||||
|
@ -169,6 +171,7 @@ std::pair<String, int> ShellManager::eval(
|
|||
return;
|
||||
}
|
||||
contents += StringView{buffer, buffer+size};
|
||||
}
|
||||
})
|
||||
{}
|
||||
};
|
||||
|
@ -227,7 +230,7 @@ std::pair<String, int> ShellManager::eval(
|
|||
if (wait_notified) // clear the status line
|
||||
context.print_status({ "", get_face("Information") }, true);
|
||||
|
||||
return { stdout_contents, WIFEXITED(status) ? WEXITSTATUS(status) : -1 };
|
||||
return { std::move(stdout_contents), WIFEXITED(status) ? WEXITSTATUS(status) : -1 };
|
||||
}
|
||||
|
||||
void ShellManager::register_env_var(StringView str, bool prefix,
|
||||
|
|
Loading…
Reference in New Issue
Block a user