From 3c86f70feec63a36f42458f2a257e27eb9d262b1 Mon Sep 17 00:00:00 2001 From: wangmengc Date: Mon, 25 Sep 2023 15:26:37 +0800 Subject: [PATCH] add without job control, end job control and restart job control function --- bash-5.1/r_jobs/src/lib.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/bash-5.1/r_jobs/src/lib.rs b/bash-5.1/r_jobs/src/lib.rs index 7a4004e6..d7a33e79 100644 --- a/bash-5.1/r_jobs/src/lib.rs +++ b/bash-5.1/r_jobs/src/lib.rs @@ -4925,8 +4925,35 @@ pub unsafe extern "C" fn set_job_control(mut arg: c_int) -> c_int { return old; } - - +#[no_mangle] +pub unsafe extern "C" fn without_job_control() { + stop_making_children(); + start_pipeline(); + sh_closepipe(pgrp_pipe.as_mut_ptr()); + delete_all_jobs(0 ); + set_job_control(0 ); +} +#[no_mangle] +pub unsafe extern "C" fn end_job_control() { + if job_control != 0 { + terminate_stopped_jobs(); + } + if original_pgrp >= 0 as c_int && terminal_pgrp != original_pgrp { + give_terminal_to(original_pgrp, 1 ); + } + if original_pgrp >= 0 + && setpgid(0 , original_pgrp) == 0 + { + shell_pgrp = original_pgrp; + } +} +#[no_mangle] +pub unsafe extern "C" fn restart_job_control() { + if shell_tty != -1 { + libc::close(shell_tty); + } + initialize_job_control(0 ); +} -- Gitee