Đó là vì jstack -F
sử dụng cuộc gọi ptrace(2)
hệ thống để thử và truy cập dữ liệu JVM, mà thất bại nếu bạn không có các quyền:
$ strace -e all -f jstack -F 26846
...
[pid 27653] ptrace(PTRACE_ATTACH, 26846, 0, 0) = -1 EPERM (Operation not permitted)
...
Từ ptrace(2)
man:
EPERM The specified process cannot be traced. This could be because the parent
has insufficient privileges (the required capability is CAP_SYS_PTRACE);
unprivileged processes cannot trace processes that they cannot send
signals to or those running set-user-ID/set-group-ID programs, for obvious
reasons. Alternatively, the process may already be being traced, or be
init(8) (PID 1).
Xem thêm capabilities(7). Sử dụng sudo
, bạn có khả năng của root, bao gồm CAP_SYS_PTRACE
.
Nguồn
2012-12-17 16:16:42