8000 pgrep: use safe wrappers for libc functions by eduardorittner · Pull Request #412 · uutils/procps · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pgrep: use safe wrappers for libc functions #412

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

eduardorittner
Copy link

Since uutils/coreutils#7676 was merged in uucore, there are now safe wrappers for getpgrp and getsid so we use them. Pgrep is the only place they are used in procps.

@eduardorittner
Copy link
Author

Note that I also found this implementation of getsid which can probably be removed since it's pretty much identical to uucore's getsid, they only change in that this returns an Option<i32> and uucore's returns Result<pid_t, Errno>

fn getsid(pid: i32) -> Option<i32> {
unsafe {
let result = libc::getsid(pid);
if Errno::last() == Errno::UnknownErrno {
Some(result)
} else {
None
}
}
}

@cakebaker
Copy link
Contributor

To make this work there has to be a new coreutils release first :|

@eduardorittner
Copy link
Author

To make this work there has to be a new coreutils release first :|

Oh ok! Sorry I saw that coreutil's latest commit is at version "0.30.0" and that procps is also using the "0.30.0" version so I thought that wasn't needed. When that happens I'll come back to this then, in the meantime do you prefer if I leave this PR open or closed?

@cakebaker
Copy link
Contributor

You can leave it open.

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.

2 participants
0