mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-26 06:00:21 +00:00
bug: fix occasionally wrong run time reported by sysinfo (#1542)
* bug: fix occasionally wrong runtime reported by sysinfo Seems like on other platforms, sysinfo will sometimes report a run time that starts from UNIX epoch - this gives a non-sensical value of 19000+ days, and it at least looks a little more reasonable to just return 0 in this case. I guess we can also make it return N/A in the future but this is a quick fix for now. * update changelog
This commit is contained in:
parent
39672853e2
commit
32f64f4d52
3 changed files with 14 additions and 2 deletions
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
||||||
- [#1541](https://github.com/ClementTsang/bottom/pull/1541): Fix some process details not updating for macOS and Windows.
|
- [#1541](https://github.com/ClementTsang/bottom/pull/1541): Fix some process details not updating for macOS and Windows.
|
||||||
|
- [#1542](https://github.com/ClementTsang/bottom/pull/1542): Fix confusing process run times being reported on macOS.
|
||||||
- [#1543](https://github.com/ClementTsang/bottom/pull/1543): Fix the `--default_cpu_entry` argument not being checked.
|
- [#1543](https://github.com/ClementTsang/bottom/pull/1543): Fix the `--default_cpu_entry` argument not being checked.
|
||||||
|
|
||||||
## [0.10.1] - 2024-08-01
|
## [0.10.1] - 2024-08-01
|
||||||
|
|
|
@ -90,7 +90,16 @@ pub(crate) trait UnixProcessExt {
|
||||||
.ok()
|
.ok()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| "N/A".into()),
|
.unwrap_or_else(|| "N/A".into()),
|
||||||
time: Duration::from_secs(process_val.run_time()),
|
time: if process_val.start_time() == 0 {
|
||||||
|
// Workaround for sysinfo occasionally returning a start time equal to UNIX
|
||||||
|
// epoch, giving a run time in the range of 50+ years. We just
|
||||||
|
// return a time of zero in this case for simplicity.
|
||||||
|
//
|
||||||
|
// TODO: Maybe return an option instead?
|
||||||
|
Duration::ZERO
|
||||||
|
} else {
|
||||||
|
Duration::from_secs(process_val.run_time())
|
||||||
|
},
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
gpu_mem: 0,
|
gpu_mem: 0,
|
||||||
#[cfg(feature = "gpu")]
|
#[cfg(feature = "gpu")]
|
||||||
|
|
|
@ -104,9 +104,11 @@ pub fn sysinfo_process_data(
|
||||||
.and_then(|uid| users.get_user_by_id(uid))
|
.and_then(|uid| users.get_user_by_id(uid))
|
||||||
.map_or_else(|| "N/A".into(), |user| user.name().to_owned().into()),
|
.map_or_else(|| "N/A".into(), |user| user.name().to_owned().into()),
|
||||||
time: if process_val.start_time() == 0 {
|
time: if process_val.start_time() == 0 {
|
||||||
// Workaround for Windows occasionally returning a start time equal to UNIX
|
// Workaround for sysinfo occasionally returning a start time equal to UNIX
|
||||||
// epoch, giving a run time in the range of 50+ years. We just
|
// epoch, giving a run time in the range of 50+ years. We just
|
||||||
// return a time of zero in this case for simplicity.
|
// return a time of zero in this case for simplicity.
|
||||||
|
//
|
||||||
|
// TODO: Maybe return an option instead?
|
||||||
Duration::ZERO
|
Duration::ZERO
|
||||||
} else {
|
} else {
|
||||||
Duration::from_secs(process_val.run_time())
|
Duration::from_secs(process_val.run_time())
|
||||||
|
|
Loading…
Reference in a new issue