mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibCore: Port Command::write_lines to ErrorOr
Keeping this in line with Command::write.
This commit is contained in:
parent
5dd93474ee
commit
125145c682
Notes:
sideshowbarker
2024-07-17 03:27:40 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/125145c682 Pull-request: https://github.com/SerenityOS/serenity/pull/19994 Reviewed-by: https://github.com/AtkinsSJ
@ -126,7 +126,8 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||||||
}
|
}
|
||||||
auto& runner_process = runner_process_or_error.value();
|
auto& runner_process = runner_process_or_error.value();
|
||||||
|
|
||||||
if (!runner_process->write_lines(files.slice(test_index))) {
|
if (auto maybe_error = runner_process->write_lines(files.slice(test_index)); maybe_error.is_error()) {
|
||||||
|
warnln("Runner process failed writing writing file input: {}", maybe_error.error());
|
||||||
fail_all_after();
|
fail_all_after();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ ErrorOr<void> Command::write(StringView input)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Command::write_lines(Span<DeprecatedString> lines)
|
ErrorOr<void> Command::write_lines(Span<DeprecatedString> lines)
|
||||||
{
|
{
|
||||||
// It's possible the process dies before we can write everything to the
|
// It's possible the process dies before we can write everything to the
|
||||||
// stdin. So make sure that we don't crash but just stop writing.
|
// stdin. So make sure that we don't crash but just stop writing.
|
||||||
@ -72,10 +72,7 @@ bool Command::write_lines(Span<DeprecatedString> lines)
|
|||||||
action_handler.sa_handler = SIG_IGN;
|
action_handler.sa_handler = SIG_IGN;
|
||||||
|
|
||||||
struct sigaction old_action_handler;
|
struct sigaction old_action_handler;
|
||||||
if (sigaction(SIGPIPE, &action_handler, &old_action_handler) < 0) {
|
TRY(Core::System::sigaction(SIGPIPE, &action_handler, &old_action_handler));
|
||||||
perror("sigaction");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (DeprecatedString const& line : lines) {
|
for (DeprecatedString const& line : lines) {
|
||||||
if (m_stdin->write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes()).is_error())
|
if (m_stdin->write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes()).is_error())
|
||||||
@ -89,7 +86,7 @@ bool Command::write_lines(Span<DeprecatedString> lines)
|
|||||||
if (sigaction(SIGPIPE, &old_action_handler, nullptr) < 0)
|
if (sigaction(SIGPIPE, &old_action_handler, nullptr) < 0)
|
||||||
perror("sigaction");
|
perror("sigaction");
|
||||||
|
|
||||||
return true;
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<Command::ProcessOutputs> Command::read_all()
|
ErrorOr<Command::ProcessOutputs> Command::read_all()
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
ErrorOr<void> write(StringView input);
|
ErrorOr<void> write(StringView input);
|
||||||
|
|
||||||
bool write_lines(Span<DeprecatedString> lines);
|
ErrorOr<void> write_lines(Span<DeprecatedString> lines);
|
||||||
|
|
||||||
ErrorOr<ProcessOutputs> read_all();
|
ErrorOr<ProcessOutputs> read_all();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user