Uh oh!
There was an error while loading. Please reload this page.
pidwait: optimize & cross-platform - #400
Conversation
Signed-off-by: FurryR <awathefox@gmail.com>
Krysztal112233
commented
Apr 25, 2025
Thank you for your contribution, I will start reviewing soon :) |
cakebaker
commented
Apr 28, 2025
Hm, at least on my machine (using Linux) your changes make the test |
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: FurryR <awathefox@gmail.com>
Signed-off-by: FurryR <awathefox@gmail.com>
FurryR
commented
May 31, 2025
Fixed a bunch of things, now tests can be passed on Output of Requiring further tests on Windows and OpenBSD. |
Signed-off-by: FurryR <awathefox@gmail.com>
sorry that is my fault. Signed-off-by: FurryR <awathefox@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Signed-off-by: FurryR <awathefox@gmail.com> Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
FurryR
commented
Jun 9, 2025
Sorry for replying late. I am working on it right now. |
Signed-off-by: FurryR <awathefox@gmail.com>
Signed-off-by: FurryR <awathefox@gmail.com>
| pub(crate) fn wait( | ||
| procs: &[ProcessInformation], | ||
| timeout: Option<Duration>, | ||
| ) -> Result<Option<()>, std::io::Error> { |
There was a problem hiding this comment.
What's the reason for using Option<()>? Why not use ()?
There was a problem hiding this comment.
I thought that it would be better if we can pass exceptions rather than just unwrap.
There was a problem hiding this comment.
Hm, I don't understand what you mean :| I think we are talking about different things. Maybe my question was too imprecise?
My question is: why do you use Result<Option<()>, std::io::Error> instead of Result<(), std::io::Error> as return type?
There was a problem hiding this comment.
I think using Option<()> is unnecessary because the meaning of this Option is to indicate something there or nothing there, and it's clear that this function doesn't need that meaning; it only needs to know whether an error occurred
There was a problem hiding this comment.
Option<()> here:
- None means that there is no such process.
- Ok(()) means that the process exists and the function waited for the process.
It is probably useful for future uses, as you can detect if the function really did wait. idk.
| procs: &[ProcessInformation], | ||
| timeout: Option<Duration>, | ||
| ) -> Result<Option<()>, std::io::Error> { | ||
| if !procs.is_empty() { |
There was a problem hiding this comment.
A detail: I would drop the ! and swap the if and else blocks, it's a little bit easier to read.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Daniel Hofstetter <daniel.hofstetter@42dh.com>
| use std::time::Duration; | ||
| use uu_pgrep::process::ProcessInformation; | ||
| pub fn wait(procs: &[ProcessInformation], timeout: Option<Duration>) -> Result<Option<()>> { |
There was a problem hiding this comment.
| use std::time::Duration; | ||
| use uu_pgrep::process::ProcessInformation; | ||
| pub fn wait(procs: &[ProcessInformation], timeout: Option<Duration>) -> Result<Option<()>> { |
There was a problem hiding this comment.
There was a problem hiding this comment.
I noticed that there are some unsafe block in this file, and cloud you please add comments to explain why it's safety here? :)
https://github.com/uutils/coreutils/blob/main/CONTRIBUTING.md#unsafe
Resolves#399 (partially).
Needs to be reviewed before merge as it contains untested code. However it seems that at least the implementation for Linux works fine.