From 7e3ba4d7bc9b0d4b5b264f5ed23ba0293ca7b9b0 Mon Sep 17 00:00:00 2001 From: wangmengc Date: Tue, 10 Oct 2023 17:43:49 +0800 Subject: [PATCH] add cpl closeall function cpl fdchk function and cpl search function --- bash-5.1/r_execute_cmd/src/lib.rs | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index 1509741e..923570f4 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -1726,8 +1726,44 @@ pub unsafe extern "C" fn cpl_flush() coproc_list.ncoproc = 0; } +pub unsafe extern "C" fn cpl_closeall() +{ + let mut cpe:*mut cpelement; + + cpe = coproc_list.head; + while !cpe.is_null() { + coproc_close((*cpe).coproc); + cpe = (*cpe).next; + } +} +pub unsafe extern "C" fn cpl_fdchk(fd:c_int) +{ + let mut cpe:*mut cpelement; + + cpe = coproc_list.head; + while !cpe.is_null() { + coproc_checkfd((*cpe).coproc, fd); + + cpe = (*cpe).next; + } +} + +pub unsafe extern "C" fn cpl_search(pid:pid_t)-> *mut cpelement +{ + let mut cpe:*mut cpelement; + + cpe = coproc_list.head; + while !cpe.is_null() { + if (*(*cpe).coproc).c_pid == pid{ + return cpe; + } + cpe = (*cpe).next; + } + + return 0 as *mut cpelement; +} -- Gitee