Skip to content

Commit

Permalink
Use process::id instead of libc::getpid
Browse files Browse the repository at this point in the history
  • Loading branch information
tailhook committed Aug 6, 2018
1 parent da90e15 commit 6b890ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use std::net::SocketAddr;
use std::str::FromStr;
use std::path::PathBuf;
use std::sync::{RwLock, Arc};
use std::process::exit;
use std::process::{self, exit};
use std::time::Duration;

use failure::Error;
Expand Down Expand Up @@ -178,7 +178,7 @@ fn run() -> Result<(), Error> {
.unwrap_or_else(|| info::machine_id());

let stats = Arc::new(RwLock::new(stats::Stats::new(
unsafe { libc::getpid() },
process::id(),
name.clone(), hostname.clone(), cluster_name.clone(),
&machine_id,
addresses.iter().map(|x| x.to_string()).collect())));
Expand Down
6 changes: 2 additions & 4 deletions src/stats.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::default::Default;

use libc::pid_t;

use id::Id;
use super::scan::time_ms;
use super::scan;
Expand All @@ -11,7 +9,7 @@ use super::storage::StorageStats;

#[derive(Debug)]
pub struct Stats {
pub pid: pid_t,
pub pid: u32,
pub id: Id,
pub addresses_str: Vec<String>,
pub name: String,
Expand All @@ -30,7 +28,7 @@ pub struct Stats {
}

impl Stats {
pub fn new(pid: pid_t, name: String, hostname: String,
pub fn new(pid: u32, name: String, hostname: String,
cluster_name: Option<String>, id: &Id,
addresses_str: Vec<String>)
-> Stats
Expand Down

0 comments on commit 6b890ab

Please sign in to comment.