From: Bruno Haible Date: Tue, 9 Apr 2019 18:44:46 +0000 (+0200) Subject: nproc: Fix return value for privileged processes. X-Git-Tag: v1.0~4989 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=3fbebf8c8e11185e8c2ed841160e6043a0e9d925;p=gnulib.git nproc: Fix return value for privileged processes. * lib/nproc.c (num_processors_ignoring_omp): Test getuid(), not getpid(). --- diff --git a/ChangeLog b/ChangeLog index 0da6f20a61..035e411552 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2019-04-09 Bruno Haible + + nproc: Fix return value for privileged processes. + * lib/nproc.c (num_processors_ignoring_omp): Test getuid(), not + getpid(). + 2019-04-07 Bruno Haible Add copyright notices in several files. diff --git a/lib/nproc.c b/lib/nproc.c index 49d2601f57..77b8760271 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -294,7 +294,7 @@ num_processors_ignoring_omp (enum nproc_query query) MP_NAPROCS yields the number of processors available to unprivileged processes. */ int nprocs = - sysmp (query == NPROC_CURRENT && getpid () != 0 + sysmp (query == NPROC_CURRENT && getuid () != 0 ? MP_NAPROCS : MP_NPROCS); if (nprocs > 0)