Commit 717d6a51 authored by Andrew Vagin's avatar Andrew Vagin Committed by Pavel Emelyanov

cr-dump: getpriority() can return a negative value

Since getpriority() can legitimately return the value -1, it is necessary
to clear the external variable errno prior to the call, then check
it afterward to determine if -1 is an error or a legitimate value.

Cc: Filipe Brandenburger <filbranden@google.com>
Fixes: 16e673c2f6a0 ("cr-check: Inspect errno on syscall failures")
Signed-off-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Acked-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 9f5c378f
...@@ -168,9 +168,10 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc) ...@@ -168,9 +168,10 @@ static int dump_sched_info(int pid, ThreadCoreEntry *tc)
* in kernel. Thus we have to take it with us in the image. * in kernel. Thus we have to take it with us in the image.
*/ */
errno = 0;
ret = getpriority(PRIO_PROCESS, pid); ret = getpriority(PRIO_PROCESS, pid);
if (ret < 0) { if (ret == -1 && errno) {
pr_perror("Can't get nice for %d", pid); pr_perror("Can't get nice for %d ret %d", pid, ret);
return -1; return -1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment