From e1c2132a8d745b917211b8d3a7936a049865be9d Mon Sep 17 00:00:00 2001 From: wangmengc Date: Wed, 18 Oct 2023 10:24:21 +0800 Subject: [PATCH] coproc flush function,coproc close function,coproc closeall function, coproc reap function --- bash-5.1/r_execute_cmd/src/lib.rs | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index 1c2f1a0..fe01068 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -1895,8 +1895,40 @@ pub unsafe extern "C" fn coproc_dispose(mut cp: *mut coproc) { UNBLOCK_SIGNAL!(oset); } +#[no_mangle] +pub unsafe extern "C" fn coproc_flush() { + coproc_dispose(&mut sh_coproc); +} +#[no_mangle] +pub unsafe extern "C" fn coproc_close(mut cp: *mut coproc) { + if (*cp).c_rfd >= 0 { + close((*cp).c_rfd); + (*cp).c_rfd = -1; + } + if (*cp).c_wfd >= 0 { + close((*cp).c_wfd); + (*cp).c_wfd = -1; + } + let ref mut fresh27 = (*cp).c_wsave; + (*cp).c_wsave = -1; + (*cp).c_rsave = -1; +} +#[no_mangle] +pub unsafe extern "C" fn coproc_closeall() { + coproc_close(&mut sh_coproc); +} + +#[no_mangle] +pub unsafe extern "C" fn coproc_reap() { + let mut cp: *mut coproc = 0 as *mut coproc; + + cp = &mut sh_coproc; + if !cp.is_null() && (*cp).c_flags & COPROC_DEAD as libc::c_int != 0 { + coproc_dispose(cp); + } +} -- Gitee