Skip to content

Commit 52afc1a

Browse files
committed
Reuse flush_std
1 parent f0c427b commit 52afc1a

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

vm/src/vm/interpreter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl Interpreter {
8484
}
8585
}
8686

87-
fn flush_std(vm: &VirtualMachine) {
87+
pub(crate) fn flush_std(vm: &VirtualMachine) {
8888
if let Ok(stdout) = sys::get_stdout(vm) {
8989
let _ = vm.call_method(&stdout, identifier!(vm, flush).as_str(), ());
9090
}

vm/src/vm/mod.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -779,22 +779,7 @@ impl VirtualMachine {
779779
)
780780
.is_ok()
781781
{
782-
// FIXME: flush sys.stdout and sys.stderr before killing process.
783-
if let Ok(stdout) = stdlib::sys::get_stdout(self) {
784-
let _ = self.call_method(
785-
&stdout,
786-
identifier!(self, flush).as_str(),
787-
(),
788-
);
789-
}
790-
if let Ok(stderr) = stdlib::sys::get_stderr(self) {
791-
let _ = self.call_method(
792-
&stderr,
793-
identifier!(self, flush).as_str(),
794-
(),
795-
);
796-
}
797-
782+
interpreter::flush_std(self);
798783
kill(getpid(), SIGINT).expect("Expect to be killed.");
799784
}
800785
}

0 commit comments

Comments
 (0)