From 718f45492a4b2c31a67458c13c4cd4b3268703bc Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Thu, 29 Feb 2024 01:40:27 -0700 Subject: Fix handling of SIGINT Keep track of a new atomic variable: at_prompt, which is set to true just before blocking on io::stdin.read_line, and set to false just calling Poem::read. Additionally, for background tasks, there is a new ps macro called btask, which changes the process group of commands that are forked into the background, so that they don't receive SIGINT from the keyboard. --- src/recite.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/recite.rs') diff --git a/src/recite.rs b/src/recite.rs index bd72b67..1aa1a62 100644 --- a/src/recite.rs +++ b/src/recite.rs @@ -1,10 +1,11 @@ pub mod path; mod ps; -use crate::{ctask, task}; +use crate::{btask, ctask, task}; use core::fmt; use libc::{waitpid, WNOHANG}; use path::prefresh; use std::io::{self, Write}; +use std::os::unix::process::CommandExt; use std::path::Path; use std::process::{exit, Command, Stdio}; use std::sync::{Arc, Mutex}; @@ -125,7 +126,7 @@ impl Meter { out: &mut String, pids: &mut Arc>>, ) -> Result { - let child = task!(verse, out); + let child = btask!(verse, out); println!("[&] {}", child.id()); pids.lock().unwrap().push(child.id() as i32); -- cgit v1.2.3