< prev index next >

src/jdk.hotspot.agent/linux/native/libsaproc/ps_proc.c

Print this page

        

@@ -281,13 +281,14 @@
         print_debug("Thread with pid %d does not exist\n", pid);
         return ATTACH_THREAD_DEAD;
       }
     }
     char buf[200];
-    char* msg = strerror_r(errno, buf, sizeof(buf));
-    snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: %s", pid, msg);
-    print_error("%s\n", err_buf);
+    if (strerror_r(errno, buf, sizeof(buf) == 0)) {
+      snprintf(err_buf, err_buf_len, "ptrace(PTRACE_ATTACH, ..) failed for %d: %s", pid, buf);
+      print_error("%s\n", err_buf);
+    }
     return ATTACH_FAIL;
   } else {
     attach_state_t wait_ret = ptrace_waitpid(pid);
     if (wait_ret == ATTACH_THREAD_DEAD) {
       print_debug("Thread with pid %d does not exist\n", pid);
< prev index next >