strace/backport-0002-Move-print_debug_info-definition-before-cleanup.patch

91 lines
1.9 KiB
Diff
Raw Permalink Normal View History

From 651640fd5faf0e24d9cd88c596854c108f732329 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@strace.io>
Date: Fri, 24 Nov 2023 08:00:00 +0000
Subject: [PATCH] Move print_debug_info() definition before cleanup()
* src/strace.c (print_debug_info): Move before cleanup().
Reference: https://github.com/strace/strace/commit/651640fd5faf0e24d9cd88c596854c108f732329
Conflict: NA
---
src/strace.c | 56 ++++++++++++++++++++++++++--------------------------
1 file changed, 28 insertions(+), 28 deletions(-)
diff --git a/src/strace.c b/src/strace.c
index d3fa44f30..28f5b4368 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -3099,34 +3099,6 @@ pid2tcb(const int pid)
return NULL;
}
-static void
-cleanup(int fatal_sig)
-{
- if (ptrace_setoptions & PTRACE_O_EXITKILL)
- return;
-
- if (!fatal_sig)
- fatal_sig = SIGTERM;
-
- for (size_t i = 0; i < tcbtabsize; ++i) {
- struct tcb *tcp = tcbtab[i];
- if (!tcp->pid)
- continue;
- debug_func_msg("looking at pid %u", tcp->pid);
- if (tcp->pid == strace_child) {
- kill(tcp->pid, SIGCONT);
- kill(tcp->pid, fatal_sig);
- }
- detach(tcp);
- }
-}
-
-static void
-interrupt(int sig)
-{
- interrupted = sig;
-}
-
static void
print_debug_info(const int pid, int status)
{
@@ -3166,6 +3138,34 @@ print_debug_info(const int pid, int status)
error_msg("[wait(0x%06x) = %u] %s%s", status, pid, buf, evbuf);
}
+static void
+cleanup(int fatal_sig)
+{
+ if (ptrace_setoptions & PTRACE_O_EXITKILL)
+ return;
+
+ if (!fatal_sig)
+ fatal_sig = SIGTERM;
+
+ for (size_t i = 0; i < tcbtabsize; ++i) {
+ struct tcb *tcp = tcbtab[i];
+ if (!tcp->pid)
+ continue;
+ debug_func_msg("looking at pid %u", tcp->pid);
+ if (tcp->pid == strace_child) {
+ kill(tcp->pid, SIGCONT);
+ kill(tcp->pid, fatal_sig);
+ }
+ detach(tcp);
+ }
+}
+
+static void
+interrupt(int sig)
+{
+ interrupted = sig;
+}
+
static struct tcb *
maybe_allocate_tcb(const int pid, int status)
{
--
2.33.0