[LEDE-DEV,procd,14/17] utrace: Report ptrace errors

Message ID 20170912111250.31576-17-sojkam1@fel.cvut.cz
State Accepted
Headers show
Series
  • [LEDE-DEV,procd,01/17] utrace: Fix environment initialization
Related show

Commit Message

Michal Sojka Sept. 12, 2017, 11:12 a.m.
---
 trace/trace.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch

diff --git a/trace/trace.c b/trace/trace.c
index 6fbe608..eead9c5 100644
--- a/trace/trace.c
+++ b/trace/trace.c
@@ -25,6 +25,7 @@ 
 #include <errno.h>
 #include <string.h>
 #include <syslog.h>
+#include <err.h>
 
 #ifndef PTRACE_EVENT_STOP
 /* PTRACE_EVENT_STOP is defined in linux/ptrace.h, but this header
@@ -351,8 +352,10 @@  int main(int argc, char **argv, char **envp)
 		ptrace_restart = PTRACE_CONT;
 		break;
 	}
-	ptrace(PTRACE_SEIZE, child, 0, ptrace_options);
-	ptrace(ptrace_restart, child, 0, SIGCONT);
+	if (ptrace(PTRACE_SEIZE, child, 0, ptrace_options) == -1)
+		err(1, "PTRACE_SEIZE");
+	if (ptrace(ptrace_restart, child, 0, SIGCONT) == -1)
+		err(1, "ptrace restart");
 
 	uloop_init();
 	tracer.proc.pid = child;