File tree 3 files changed +41
-0
lines changed
src/test/run-make/libnative-nonblock
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ -include ../tools.mk
2
+
3
+ all :
4
+ $(RUSTC ) write.rs
5
+ $(CC ) -o $(TMPDIR ) /mknblock mknblock.c
6
+ mkfifo $(TMPDIR ) /fifo
7
+ /bin/sh -c " (sleep 1; cat) < $( TMPDIR) /fifo > /dev/null" &
8
+ /bin/sh -c " ($( TMPDIR) /mknblock; $( TMPDIR) /write) > $( TMPDIR) /fifo"
Original file line number Diff line number Diff line change
1
+ #include <fcntl.h>
2
+ #include <stdio.h>
3
+
4
+ int main () {
5
+ if (fcntl (1 , F_SETFL , O_NONBLOCK ) == -1 ) {
6
+ perror ("fcntl" );
7
+ return 1 ;
8
+ }
9
+ return 0 ;
10
+ }
Original file line number Diff line number Diff line change
1
+ use std:: io;
2
+ use std:: io:: IoResult ;
3
+ use std:: os;
4
+
5
+ fn run ( ) -> IoResult < ( ) > {
6
+ let mut out = io:: stdio:: stdout_raw ( ) ;
7
+ for _ in range ( 0 u, 32 ) {
8
+ let mut buf = [ 'x' as u8 , ..1024 ] ;
9
+ buf[ 1023 ] = '\n' as u8 ;
10
+ try!( out. write ( buf) ) ;
11
+ }
12
+ Ok ( ( ) )
13
+ }
14
+
15
+ fn main ( ) {
16
+ match run ( ) {
17
+ Err ( e) => {
18
+ ( writeln ! ( & mut io:: stderr( ) , "Error: {}" , e) ) . unwrap ( ) ;
19
+ os:: set_exit_status ( 1 ) ;
20
+ }
21
+ Ok ( ( ) ) => ( )
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments