[Toybox] [PATCH] nice.c: don't bother with getpriority().

Rob Landley rob at landley.net
Thu Aug 16 20:24:39 PDT 2012


On 08/15/2012 10:56 PM, Avery Pennarun wrote:
> The nice() syscall returns either 0 for success (very old Linux kernels) or
> the new niceness (which might be -1).  To check whether it was successful,
> the nice(2) manpage says you should zero out errno, then if nice() returns
> -1, check that errno is nonzero, and if it is, that's your error.
> 
> We could call getpriority(), but the way it was being done is incorrect.
> getpriority() includes the *absolute* priority of the process, while nice()
> adjusts the priority incrementally.  To use getpriority() correctly, we'd
> have to get the priority before and after, and cap it at the
> kernel-dependent range, and make sure the *delta* is the one we requested
> with nice(2).  This is unnecessary since the return value of nice() is
> perfectly sufficient.

I'm not sure the check for -1 is even required (would nice set errno
nonzero when there wasn't an error) but I left it in.

Thanks,

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.

 1345173879.0


More information about the Toybox mailing list