diff options
author | Santo Cariotti <santo@dcariotti.me> | 2023-10-16 14:16:25 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2023-10-16 14:16:25 +0200 |
commit | 8c0c901fb1c508ba878aeaf371084daeebe52a24 (patch) | |
tree | 99a2b30817c4646b648dce9a0d35a8234dbaec41 /src/ui.rs | |
parent | c7d99a1dff61d64ffc26caa8068cf41d5202af3b (diff) |
Avoid `run_loop` flag
Diffstat (limited to 'src/ui.rs')
-rw-r--r-- | src/ui.rs | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -8,7 +8,7 @@ use crossterm::{ terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, ExecutableCommand, }; -use nix::unistd::Pid; +use nix::{sys::wait::waitpid, unistd::Pid}; use ratatui::{prelude::*, widgets::*}; use std::io::{self, stdout}; @@ -66,12 +66,16 @@ impl UI { let mut have_to_trace = !args.command.is_some(); let mut should_quit = false; - let lines = trace(pid, &args, args.command.is_some())?; - if lines.len() > 1 { - for line in lines { - self.add_line(line); + if args.command.is_some() { + let registers = trace(pid, &args)?; + for register in registers { + self.add_line(register); } + } else { + // First wait for the parent process + _ = waitpid(pid, None)?; } + while !should_quit { if have_to_trace { if let Some(reg) = trace_next(pid)? { |