diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-05 12:01:24 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2016-10-05 12:01:24 +0200 |
commit | acfe6b2bba2dee5e9ab19335dd22cc31d6092553 (patch) | |
tree | 6f98f0653a73edbd37777ce4578dadf06a352747 /psutil/_psutil_common.c | |
parent | 8dfc2d0cf4dfe5634697ab250d3f034642d97e91 (diff) | |
download | psutil-acfe6b2bba2dee5e9ab19335dd22cc31d6092553.tar.gz |
update comments
Diffstat (limited to 'psutil/_psutil_common.c')
-rw-r--r-- | psutil/_psutil_common.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index 6157c3a7..e333c162 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -58,12 +58,12 @@ psutil_pid_exists(long pid) { if (pid < 0) return 0; - // As per "man 2 kill" PID 0 is an alias for sending the seignal to - // every process in the process group of the calling process. - // Not what we want. + // As per "man 2 kill" PID 0 is an alias for sending the signal to + // every process in the process group of the calling process. + // Not what we want. Some platforms have PID 0, some do not. + // We decide that at runtime. if (pid == 0) { #if defined(PSUTIL_LINUX) || defined(PSUTIL_FREEBSD) - // PID 0 does not exist on these platforms. return 0; #else return 1; @@ -74,11 +74,20 @@ psutil_pid_exists(long pid) { if (ret == 0) return 1; else { - if (errno == ESRCH) + if (errno == ESRCH) { + // ESRCH == No such process return 0; - else if (errno == EPERM) + } + else if (errno == EPERM) { + // EPERM clearly indicates there's a process to deny + // access to. return 1; + } else { + // According to "man 2 kill" possible error values are + // (EINVAL, EPERM, ESRCH) therefore we should never get + // here. If we do let's be explicit in considering this + // an error. PyErr_SetFromErrno(PyExc_OSError); return -1; } |