[CRIU] [PATCH] cr-dump: getpriority() can return a negative value
Andrey Vagin
avagin at openvz.org
Mon Mar 14 23:23:30 PDT 2016
From: Andrew Vagin <avagin at virtuozzo.com>
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 at google.com>
Fixes: 16e673c2f6a0 ("cr-check: Inspect errno on syscall failures")
Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
criu/cr-dump.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/criu/cr-dump.c b/criu/cr-dump.c
index ad5a970..2556cb2 100644
--- a/criu/cr-dump.c
+++ b/criu/cr-dump.c
@@ -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.
*/
+ errno = 0;
ret = getpriority(PRIO_PROCESS, pid);
- if (ret < 0) {
- pr_perror("Can't get nice for %d", pid);
+ if (ret == -1 && errno) {
+ pr_perror("Can't get nice for %d ret %d", pid, ret);
return -1;
}
--
2.5.0
More information about the CRIU
mailing list