1
1
use std:: fs:: File ;
2
- use std:: io:: { Read , Write } ;
2
+ use std:: io:: { stdout , Read , Write } ;
3
3
use std:: os:: unix:: prelude:: * ;
4
4
use std:: path:: Path ;
5
5
6
- use libc:: { _exit, STDOUT_FILENO } ;
6
+ use libc:: _exit;
7
7
use nix:: fcntl:: { open, OFlag } ;
8
8
use nix:: pty:: * ;
9
9
use nix:: sys:: stat;
@@ -185,7 +185,7 @@ fn test_openpty() {
185
185
// Writing to one should be readable on the other one
186
186
let string = "foofoofoo\n " ;
187
187
let mut buf = [ 0u8 ; 10 ] ;
188
- write ( pty. master . as_raw_fd ( ) , string. as_bytes ( ) ) . unwrap ( ) ;
188
+ write ( & pty. master , string. as_bytes ( ) ) . unwrap ( ) ;
189
189
crate :: read_exact ( & pty. slave , & mut buf) ;
190
190
191
191
assert_eq ! ( & buf, string. as_bytes( ) ) ;
@@ -199,7 +199,7 @@ fn test_openpty() {
199
199
let string2 = "barbarbarbar\n " ;
200
200
let echoed_string2 = "barbarbarbar\r \n " ;
201
201
let mut buf = [ 0u8 ; 14 ] ;
202
- write ( pty. slave . as_raw_fd ( ) , string2. as_bytes ( ) ) . unwrap ( ) ;
202
+ write ( & pty. slave , string2. as_bytes ( ) ) . unwrap ( ) ;
203
203
crate :: read_exact ( & pty. master , & mut buf) ;
204
204
205
205
assert_eq ! ( & buf, echoed_string2. as_bytes( ) ) ;
@@ -224,7 +224,7 @@ fn test_openpty_with_termios() {
224
224
// Writing to one should be readable on the other one
225
225
let string = "foofoofoo\n " ;
226
226
let mut buf = [ 0u8 ; 10 ] ;
227
- write ( pty. master . as_raw_fd ( ) , string. as_bytes ( ) ) . unwrap ( ) ;
227
+ write ( & pty. master , string. as_bytes ( ) ) . unwrap ( ) ;
228
228
crate :: read_exact ( & pty. slave , & mut buf) ;
229
229
230
230
assert_eq ! ( & buf, string. as_bytes( ) ) ;
@@ -237,7 +237,7 @@ fn test_openpty_with_termios() {
237
237
let string2 = "barbarbarbar\n " ;
238
238
let echoed_string2 = "barbarbarbar\n " ;
239
239
let mut buf = [ 0u8 ; 13 ] ;
240
- write ( pty. slave . as_raw_fd ( ) , string2. as_bytes ( ) ) . unwrap ( ) ;
240
+ write ( & pty. slave , string2. as_bytes ( ) ) . unwrap ( ) ;
241
241
crate :: read_exact ( & pty. master , & mut buf) ;
242
242
243
243
assert_eq ! ( & buf, echoed_string2. as_bytes( ) ) ;
@@ -258,7 +258,7 @@ fn test_forkpty() {
258
258
let pty = unsafe { forkpty ( None , None ) . unwrap ( ) } ;
259
259
match pty. fork_result {
260
260
Child => {
261
- write ( STDOUT_FILENO , string. as_bytes ( ) ) . unwrap ( ) ;
261
+ write ( stdout ( ) , string. as_bytes ( ) ) . unwrap ( ) ;
262
262
pause ( ) ; // we need the child to stay alive until the parent calls read
263
263
unsafe {
264
264
_exit ( 0 ) ;
0 commit comments