From 6cbc4ce87f19972007b689078aceb54014106fae Mon Sep 17 00:00:00 2001 From: Adrian Muzyka Date: Wed, 20 Sep 2023 08:54:56 +0200 Subject: [PATCH] Ignore ptrace(PTRACE_SEIZE) error on ESRCH (No such process) --- memcr.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/memcr.c b/memcr.c index 6f77dd7..c292ebd 100644 --- a/memcr.c +++ b/memcr.c @@ -448,7 +448,12 @@ static int seize_pid(pid_t pid) ret = ptrace(PTRACE_SEIZE, pid, NULL, 0); if (ret) { - fprintf(stderr, "ptrace(PTRACE_SEIZE) pid %d: %m\n", pid); + if (errno == ESRCH) { + fprintf(stderr, "ptrace(PTRACE_SEIZE) pid %d: %m, ignoring\n", pid); + return 0; + } + + fprintf(stderr, "ptrace(PTRACE_SEIZE) %d pid %d: %m\n", errno, pid); return 1; }