Skip to content

Commit f54d42e

Browse files
committed
[miri] make closing stdio file descriptions noops
std supports redirecting stdio file descriptors.
1 parent 1cd8752 commit f54d42e

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

src/tools/miri/src/shims/files.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ impl FileDescription for io::Stdin {
249249
finish.call(ecx, result)
250250
}
251251

252+
fn destroy<'tcx>(
253+
self,
254+
_self_id: FdId,
255+
_communicate_allowed: bool,
256+
_ecx: &mut MiriInterpCx<'tcx>,
257+
) -> InterpResult<'tcx, io::Result<()>> {
258+
interp_ok(Ok(()))
259+
}
260+
252261
fn is_tty(&self, communicate_allowed: bool) -> bool {
253262
communicate_allowed && self.is_terminal()
254263
}
@@ -279,6 +288,15 @@ impl FileDescription for io::Stdout {
279288
finish.call(ecx, result)
280289
}
281290

291+
fn destroy<'tcx>(
292+
self,
293+
_self_id: FdId,
294+
_communicate_allowed: bool,
295+
_ecx: &mut MiriInterpCx<'tcx>,
296+
) -> InterpResult<'tcx, io::Result<()>> {
297+
interp_ok(Ok(()))
298+
}
299+
282300
fn is_tty(&self, communicate_allowed: bool) -> bool {
283301
communicate_allowed && self.is_terminal()
284302
}
@@ -289,6 +307,15 @@ impl FileDescription for io::Stderr {
289307
"stderr"
290308
}
291309

310+
fn destroy<'tcx>(
311+
self,
312+
_self_id: FdId,
313+
_communicate_allowed: bool,
314+
_ecx: &mut MiriInterpCx<'tcx>,
315+
) -> InterpResult<'tcx, io::Result<()>> {
316+
interp_ok(Ok(()))
317+
}
318+
292319
fn write<'tcx>(
293320
self: FileDescriptionRef<Self>,
294321
_communicate_allowed: bool,
@@ -436,6 +463,15 @@ impl FileDescription for NullOutput {
436463
// We just don't write anything, but report to the user that we did.
437464
finish.call(ecx, Ok(len))
438465
}
466+
467+
fn destroy<'tcx>(
468+
self,
469+
_self_id: FdId,
470+
_communicate_allowed: bool,
471+
_ecx: &mut MiriInterpCx<'tcx>,
472+
) -> InterpResult<'tcx, io::Result<()>> {
473+
interp_ok(Ok(()))
474+
}
439475
}
440476

441477
/// Internal type of a file-descriptor - this is what [`FdTable`] expects

0 commit comments

Comments
 (0)