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

Add ProcError::Incomplete #27

Merged
merged 3 commits into from
Mar 5, 2019
Merged

Conversation

dalance
Copy link
Contributor

@dalance dalance commented Mar 1, 2019

Rarely from_reader seems to be panic.
For example, the following code becomes panic once every 30 minutes - 1 hour.

fn main() {
    loop {
        std::panic::catch_unwind(|| {
            for p in procfs::all_processes() {
                p.io();
                p.status();
                p.maps();
                p.mountstats();
            }
        });
    }
}

Panic occurs at Stat::from_reader, Status::from_reader and Io::from_reader.
(Process::maps and MountStat::from_reader are no problem)

This is because that opening procfs file is success but reading the contents is failed.
Usually contents seems to be empty, but sometimes incomplete contents is read.

To handle this error, I added ProcError::Incomplete and removed unwrap in the code of parsing contents.

@dalance
Copy link
Contributor Author

dalance commented Mar 1, 2019

After 8 hours execution, Process::maps becomes panic.
I think MountStat::from_reader should be fixed too.

@eminence eminence self-assigned this Mar 4, 2019
@eminence
Copy link
Owner

eminence commented Mar 5, 2019

Sorry for taking so long to review this. And thanks a lot for this change (and all of the others you have made) -- it's really helped to improve the procfs library.

This sounds good to me. I'm going to test it (via your small test loop) on my personal computers, as well as some computers at work which are heavily loaded and see lots of process churn. In the meantime, I'll merge this.

@eminence eminence merged commit 8e36e3f into eminence:master Mar 5, 2019
@dalance
Copy link
Contributor Author

dalance commented Mar 5, 2019

Thanks

@dalance dalance deleted the error_incomplete branch March 5, 2019 05:02
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.

None yet

2 participants