fix: handle SIGPIPE
This commit is contained in:
parent
9f40e46043
commit
cc909e20e1
3 changed files with 14 additions and 0 deletions
|
|
@ -15,6 +15,9 @@ Author: Leonardo de Moura
|
|||
#include <unistd.h> // NOLINT
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
#ifndef LEAN_WINDOWS
|
||||
#include <csignal>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
|
|
@ -653,6 +656,10 @@ void initialize_io() {
|
|||
mark_persistent(g_stream_stderr);
|
||||
g_stream_stdin = lean_stream_of_handle(io_wrap_handle(stdin));
|
||||
mark_persistent(g_stream_stdin);
|
||||
#ifndef LEAN_WINDOWS
|
||||
// We want to handle SIGPIPE ourselves
|
||||
lean_always_assert(signal(SIGPIPE, SIG_IGN) != SIG_ERR);
|
||||
#endif
|
||||
}
|
||||
|
||||
void finalize_io() {
|
||||
|
|
|
|||
|
|
@ -15,3 +15,9 @@ open IO.Process
|
|||
child.stdin.flush;
|
||||
child.wait;
|
||||
child.stdout.readToEnd
|
||||
|
||||
#eval do
|
||||
child ← spawn { cmd := "true", stdin := Stdio.piped };
|
||||
child.wait;
|
||||
child.stdin.putStrLn "ha!";
|
||||
child.stdin.flush <|> IO.println "flush of broken pipe failed"
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@ hi!
|
|||
0
|
||||
"ho!\n"
|
||||
"hu!\n"
|
||||
flush of broken pipe failed
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue