From 58da39ac20a658ab7c049cd1f13dfb26e6313ab4 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Sun, 1 Dec 2024 08:55:44 +1300 Subject: [PATCH] Set up our signal-handling info to mimic the new effects of `Task::set_up_process()` --- src/RecordTask.cc | 11 ++++++----- src/Task.cc | 4 +++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/RecordTask.cc b/src/RecordTask.cc index 3e4302fd818..0af7ff20fd3 100644 --- a/src/RecordTask.cc +++ b/src/RecordTask.cc @@ -207,13 +207,14 @@ RecordTask::RecordTask(RecordSession& session, pid_t _tid, uint32_t serial, schedule_frozen(false) { push_event(Event::sentinel()); if (session.tasks().empty()) { - // Initial tracee. It inherited its state from this process, so set it up. - // The very first task we fork inherits the signal - // dispositions of the current OS process (which should all be - // default at this point, but ...). From there on, new tasks - // will transitively inherit from this first task. + // Initial tracee. auto sh = Sighandlers::create(); sh->init_from_current_process(); + // Task::set_up_process resets all non-RT signals to + // default handling, so mimic that now. + for (int sig = 1; sig <= 31; ++sig) { + reset_handler(&sh->get(sig), arch()); + } sighandlers.swap(sh); own_namespace_rec_tid = _tid; } diff --git a/src/Task.cc b/src/Task.cc index 91e966863d9..bc47251752a 100644 --- a/src/Task.cc +++ b/src/Task.cc @@ -3561,7 +3561,9 @@ static void set_up_process(Session& session, const ScopedFd& err_fd, TraceeAttentionSet::get_original_sigmask(&sigmask); sigprocmask(SIG_SETMASK, &sigmask, nullptr); - // Stop igoring signals. + // When creating a detach-teleport child, this task inherits signal + // handling set up by RecordCommand. So reset non-RT signal handlers + // to defaults now. for (int sig = 1; sig <= 31; ++sig) { signal(sig, SIG_DFL); }