summary refs log tree commit diff
path: root/extrace.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-06-13 15:50:17 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-06-13 15:50:17 +0200
commit42f0b52d8fae12f2bbe82111a7312bf5d66fcb6b (patch)
treebfba938894f0008ca43753bd6b209b6bdcfe54ee /extrace.c
parent9dc80af52106832b1ad58868c4c0314c93e9f6d5 (diff)
downloadextrace-42f0b52d8fae12f2bbe82111a7312bf5d66fcb6b.tar.gz
extrace-42f0b52d8fae12f2bbe82111a7312bf5d66fcb6b.tar.xz
extrace-42f0b52d8fae12f2bbe82111a7312bf5d66fcb6b.zip
check fscanf return value
Diffstat (limited to 'extrace.c')
-rw-r--r--extrace.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/extrace.c b/extrace.c
index 50506ce..560481a 100644
--- a/extrace.c
+++ b/extrace.c
@@ -101,7 +101,8 @@ pid_depth(pid_t pid)
   snprintf(name, sizeof name, "/proc/%d/stat", pid);
 
   if ((f = fopen(name, "r"))) {
-    fscanf(f, "%*d (%*[^)]) %*c %d", &ppid);
+    if (fscanf(f, "%*d (%*[^)]) %*c %d", &ppid) < 0)
+      ppid = 0;
     fclose(f);
   }