diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-18 22:02:13 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-18 22:02:13 +0200 |
commit | d58c4338d64fad9b3c0eebb2451cd55f660e86cf (patch) | |
tree | 5592600f979311734568c2e1a6679a5730f71275 | |
parent | 7fbf19d0f04730983265bb494460929f708475c5 (diff) | |
download | psutil-d58c4338d64fad9b3c0eebb2451cd55f660e86cf.tar.gz |
add notes about #1082
-rw-r--r-- | psutil/_pssunos.py | 9 | ||||
-rw-r--r-- | psutil/_psutil_sunos.c | 23 |
2 files changed, 20 insertions, 12 deletions
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py index 6fbb3731..b1ba6b45 100644 --- a/psutil/_pssunos.py +++ b/psutil/_pssunos.py @@ -424,13 +424,18 @@ class Process(object): @wrap_exceptions def nice_get(self): - # For some reason getpriority(3) return ESRCH (no such process) - # for certain low-pid processes, no matter what (even as root). + # Note #1: for some reason getpriority(3) return ESRCH (no such + # process) for certain low-pid processes, no matter what (even + # as root). # The process actually exists though, as it has a name, # creation time, etc. # The best thing we can do here appears to be raising AD. # Note: tested on Solaris 11; on Open Solaris 5 everything is # fine. + # + # Note #2: we also can get niceness from /proc/pid/psinfo + # but it's wrong, see: + # https://github.com/giampaolo/psutil/issues/1082 try: return cext_posix.getpriority(self.pid) except EnvironmentError as err: diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index eba71ec5..e3eb2560 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -99,16 +99,19 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) { sprintf(path, "%s/%i/psinfo", procfs_path, pid); if (! psutil_file_to_struct(path, (void *)&info, sizeof(info))) return NULL; - return Py_BuildValue("ikkdiiik", - info.pr_ppid, // parent pid - info.pr_rssize, // rss - info.pr_size, // vms - PSUTIL_TV2DOUBLE(info.pr_start), // create time - info.pr_lwp.pr_nice, // nice - info.pr_nlwp, // no. of threads - info.pr_lwp.pr_state, // status code - info.pr_ttydev // tty nr - ); + return Py_BuildValue( + "ikkdiiik", + info.pr_ppid, // parent pid + info.pr_rssize, // rss + info.pr_size, // vms + PSUTIL_TV2DOUBLE(info.pr_start), // create time + // XXX - niceness is wrong (20 instead of 0), see: + // https://github.com/giampaolo/psutil/issues/1082 + info.pr_lwp.pr_nice, // nice + info.pr_nlwp, // no. of threads + info.pr_lwp.pr_state, // status code + info.pr_ttydev // tty nr + ); } |