File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -175,11 +175,12 @@ void moonbitlang_async_init_thread_pool(int notify_send) {
175175 pthread_sigmask (SIG_BLOCK , & pool .wakeup_signal , & pool .old_sigmask );
176176#endif
177177
178- sigset_t sigpipe ;
179- sigemptyset (& sigpipe );
180- sigaddset (& sigpipe , SIGPIPE );
181- sigaddset (& sigpipe , SIGCHLD );
182- pthread_sigmask (SIG_BLOCK , & sigpipe , 0 );
178+ sigset_t signals_to_block ;
179+ sigemptyset (& signals_to_block );
180+ sigaddset (& signals_to_block , SIGCHLD );
181+ pthread_sigmask (SIG_BLOCK , & signals_to_block , 0 );
182+
183+ signal (SIGPIPE , SIG_IGN );
183184
184185 pool .notify_send = notify_send ;
185186 pool .initialized = 1 ;
Original file line number Diff line number Diff line change 1010 "targets" : {
1111 "ffi.mbt" : [ " native" ],
1212 "pipe.mbt" : [ " native" ],
13- "read_exactly_test.mbt" : [ " native" ]
13+ "read_exactly_test.mbt" : [ " native" ],
14+ "reader_closed_test.mbt" : [ " native" ]
1415 }
1516}
Original file line number Diff line number Diff line change 1+ // Copyright 2025 International Digital Economy Academy
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // http://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ ///|
16+ async test "reader closed" {
17+ let (r , w ) = @pipe .pipe ()
18+ r .close ()
19+ @async .sleep (100 )
20+ assert_true ((try ? w .write ("abcd" )) is Err (_ ))
21+ }
You can’t perform that action at this time.
0 commit comments