Skip to content

Commit

Permalink
Add a uname function specifically for illumos
Browse files Browse the repository at this point in the history
  • Loading branch information
martintc committed Apr 25, 2022
1 parent 70c37c3 commit 6aed94e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions os_info/src/uname.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ pub fn uname() -> Option<String> {
})
}

#[cfg(target_os = "illumos")]
pub fn uname() -> Option<String> {
Command::new("uname")
.arg("-v")
.output()
.map_err(|e| {
error!("Failed to invoke 'uname': {:?}", e);
})
.ok()
.and_then(|out| {
if out.status.success() {
Some(String::from_utf8_lossy(&out.stdout).trim_end().to_owned())
} else {
log::error!("'uname' invocation error: {:?}", out);
None
}
})
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 6aed94e

Please sign in to comment.