mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
setpriority test: Linux fix when RLIMIT_NICE set
Linux has a resource limit for scheduling priority. If the value is 0, processes that have increased their nice value (i.e., set it to a positive integer between 0 and 20) may not decrease it. If the value is 20, the user may decrease the process priority back to 0. Uniformly test for this resource limit across all OS'es (even though only linux seems to support it) and set it down to 0 for the test.
This commit is contained in:
@@ -558,6 +558,17 @@ priority(#state{os = {unix,_}, pid = Drv}) ->
|
||||
Prio0 = alcove:getpriority(Drv, [Fork0,Fork1], prio_process, 0),
|
||||
ok = alcove:setpriority(Drv, [Fork0,Fork1], prio_process, 0, 10),
|
||||
Prio1 = alcove:getpriority(Drv, [Fork0,Fork1], prio_process, 0),
|
||||
|
||||
case alcove:getrlimit(Drv, [Fork0,Fork1], rlimit_nice) of
|
||||
{error,einval} ->
|
||||
ok;
|
||||
{ok, #alcove_rlimit{cur = Cur}} when Cur =:= 0 ->
|
||||
ok;
|
||||
{ok, #alcove_rlimit{}} ->
|
||||
alcove:setrlimit(Drv, [Fork0,Fork1], rlimit_nice,
|
||||
#alcove_rlimit{cur = 0, max = 0})
|
||||
end,
|
||||
|
||||
ok = alcove:setuid(Drv, [Fork0,Fork1], 65534),
|
||||
Eacces = alcove:setpriority(Drv, [Fork0,Fork1], prio_process, 0, 1),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user