File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: a33bc56e43adbdfce78c63337c175053038f3362
2
+ refs/heads/master: a14e5e70462fed497ce8e12e52c1ef099678a8de
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ fn start_program(str prog, vec[str] args) -> @program {
50
50
os:: libc:: close ( pipe_input. _0 ) ;
51
51
os:: libc:: close ( pipe_output. _1 ) ;
52
52
obj new_program ( int pid,
53
- int in_fd,
53
+ mutable int in_fd,
54
54
os:: libc:: FILE out_file,
55
55
mutable bool finished) {
56
56
fn get_id ( ) -> int { ret pid; }
@@ -60,14 +60,23 @@ fn start_program(str prog, vec[str] args) -> @program {
60
60
fn output ( ) -> io:: reader {
61
61
ret io:: new_reader ( io:: FILE_buf_reader ( out_file, false ) ) ;
62
62
}
63
- fn close_input ( ) { os:: libc:: close ( in_fd) ; }
63
+ fn close_input ( ) {
64
+ auto invalid_fd = -1 ;
65
+ if ( in_fd != invalid_fd) {
66
+ os:: libc:: close ( in_fd) ;
67
+ in_fd = invalid_fd;
68
+ }
69
+ }
64
70
fn finish ( ) -> int {
65
71
if ( finished) { ret 0 ; }
66
72
finished = true ;
67
- os :: libc :: close ( in_fd ) ;
73
+ self . close_input ( ) ;
68
74
ret os:: waitpid ( pid) ;
69
75
} drop {
70
- if ( !finished) { os:: libc:: close ( in_fd) ; os:: waitpid ( pid) ; }
76
+ self. close_input ( ) ;
77
+ if ( !finished) {
78
+ os:: waitpid ( pid) ;
79
+ }
71
80
os:: libc:: fclose ( out_file) ;
72
81
}
73
82
}
You can’t perform that action at this time.
0 commit comments