doc, win: improve os.setPriority documentation

PR-URL: https://github.com/nodejs/node/pull/22817
Fixes: https://github.com/nodejs/node/issues/22799
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Bartosz Sosnowski 2018-09-12 11:07:00 +02:00 committed by Daniel Bevenius
parent a1381fab8a
commit 6e746f1a55
2 changed files with 6 additions and 1 deletions

View File

@ -371,6 +371,9 @@ priority classes, `priority` is mapped to one of six priority constants in
mapping may cause the return value to be slightly different on Windows. To avoid mapping may cause the return value to be slightly different on Windows. To avoid
confusion, it is recommended to set `priority` to one of the priority constants. confusion, it is recommended to set `priority` to one of the priority constants.
On Windows setting priority to `PRIORITY_HIGHEST` requires elevated user,
otherwise the set priority will be silently reduced to `PRIORITY_HIGH`.
## os.tmpdir() ## os.tmpdir()
<!-- YAML <!-- YAML
added: v0.9.9 added: v0.9.9

View File

@ -116,8 +116,10 @@ function checkPriority(pid, expected) {
return; return;
} }
// On Windows setting PRIORITY_HIGHEST will only work for elevated user,
// for others it will be silently reduced to PRIORITY_HIGH
if (expected < PRIORITY_HIGH) if (expected < PRIORITY_HIGH)
assert.strictEqual(priority, PRIORITY_HIGHEST); assert.ok(priority === PRIORITY_HIGHEST || priority === PRIORITY_HIGH);
else if (expected < PRIORITY_ABOVE_NORMAL) else if (expected < PRIORITY_ABOVE_NORMAL)
assert.strictEqual(priority, PRIORITY_HIGH); assert.strictEqual(priority, PRIORITY_HIGH);
else if (expected < PRIORITY_NORMAL) else if (expected < PRIORITY_NORMAL)