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

feat(node/os): implement getPriority, setPriority & userInfo #19370

Merged
merged 23 commits into from
Jul 31, 2023

Conversation

crowlKats
Copy link
Member

@crowlKats crowlKats commented Jun 5, 2023

Takes #4202 over
Closes #17850

Co-authored-by: ecyrbe ecyrbe@gmail.com

@crowlKats crowlKats marked this pull request as ready for review June 12, 2023 08:02
@kt3k
Copy link
Member

kt3k commented Jun 12, 2023

permissions for added ops

maybe --allow-sys=getPriority,setPriority,userName?

gid = -1;
}

let _homedir = homedir();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is incorrect, as per node docs:

The value of homedir returned by os.userInfo() is provided by the operating system. This differs from the result of os.homedir(), which queries environment variables for the home directory before falling back to the operating system response.

I am unsure however how to do this, and think overall this should be good enough

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd like a second pair of eyes on the Windows bits. Nice work @crowlKats

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

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

Looks good to me, but left some nitpicks.

ext/node/ops/os.rs Outdated Show resolved Hide resolved
ext/node/ops/os.rs Outdated Show resolved Hide resolved
ext/node/ops/os.rs Outdated Show resolved Hide resolved
ext/node/ops/os.rs Outdated Show resolved Hide resolved
ext/node/ops/os.rs Outdated Show resolved Hide resolved
ext/node/ops/os.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

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

dsherret's comments should be addressed.

name: "APIs not yet implemented",
name: "os.setPriority() & os.getPriority()",
// disabled because os.getPriority() doesn't work without sudo
ignore: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion: Just to be extra cool maybe only disable this if user ID is non-zero? ie. When not being run as sudo.

pub fn get_priority(pid: u32) -> Result<i32, AnyError> {
set_errno(Errno(0));
match (
// SAFETY: libc::getpriority is unsafe
Copy link
Collaborator

Choose a reason for hiding this comment

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

nitpick: Not much of a safety comment :)

@bartlomieju
Copy link
Member

@crowlKats can we aim to land this PR for v1.36?

@crowlKats
Copy link
Member Author

@bartlomieju yes

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice work Leo

@crowlKats crowlKats merged commit aa8078b into denoland:main Jul 31, 2023
@crowlKats crowlKats deleted the node_os branch July 31, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support missing node/os functionality
5 participants