Skip to content

Commit

Permalink
Set up our signal-handling info to mimic the new effects of `Task::se…
Browse files Browse the repository at this point in the history
…t_up_process()`
  • Loading branch information
rocallahan committed Nov 30, 2024
1 parent 84b7de5 commit 58da39a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/RecordTask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion src/Task.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 58da39a

Please sign in to comment.