From acec746914380ba78ac668c3b676fdd198e3e66d Mon Sep 17 00:00:00 2001 From: wangmengc Date: Wed, 18 Oct 2023 11:09:17 +0800 Subject: [PATCH] add coproc pidchk function, coproc active function,INVALID_NAMEREF_VALUE macro, att_nameref macro,nameref_p macro --- bash-5.1/r_execute_cmd/src/lib.rs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/bash-5.1/r_execute_cmd/src/lib.rs b/bash-5.1/r_execute_cmd/src/lib.rs index 2366482..5eb1022 100644 --- a/bash-5.1/r_execute_cmd/src/lib.rs +++ b/bash-5.1/r_execute_cmd/src/lib.rs @@ -1999,7 +1999,45 @@ unsafe extern "C" fn coproc_setstatus(mut cp: *mut coproc, mut status: libc::c_i (*cp).c_lock = 0 as libc::c_int; } +#[no_mangle] +pub unsafe extern "C" fn coproc_pidchk(mut pid: pid_t, mut status: libc::c_int) { + let mut cp: *mut coproc = 0 as *mut coproc; + + cp = getcoprocbypid(pid); + if !cp.is_null() { + coproc_setstatus(cp, status); + } +} + +#[no_mangle] +pub unsafe extern "C" fn coproc_active() -> pid_t { + return if sh_coproc.c_flags & COPROC_DEAD as libc::c_int != 0 { + NO_PID!() + } else { + sh_coproc.c_pid + }; +} +#[macro_export] +macro_rules! INVALID_NAMEREF_VALUE { + () => { + &mut nameref_invalid_value as *mut SHELL_VAR + }; +} + +#[macro_export] +macro_rules! att_nameref { + () => { + 0x0000800 + }; +} + +#[macro_export] +macro_rules! nameref_p { + ($var:expr) => { + (*$var).attributes & att_nameref!() + }; +} -- Gitee