Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc, win: improve os.setPriority documentation #22817

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/os.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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()
<!-- YAML
added: v0.9.9
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-os-process-priority.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ function checkPriority(pid, expected) {
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)
assert.strictEqual(priority, PRIORITY_HIGHEST);
assert.ok(priority === PRIORITY_HIGHEST || priority === PRIORITY_HIGH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of doing this for all cases, can we make an explicit check for Windows and possibly for elevated user status before making this kind of assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for Windows only (see line 114)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, can we check for elevated status then? Perhaps using this method or something similar (without 3rd party utilities)?

else if (expected < PRIORITY_ABOVE_NORMAL)
assert.strictEqual(priority, PRIORITY_HIGH);
else if (expected < PRIORITY_NORMAL)
Expand Down