Skip to content

Commit

Permalink
chore: sysinfo 0.31.0 refresh_processes now requires arg
Browse files Browse the repository at this point in the history
  • Loading branch information
YOU54F committed Aug 21, 2024
1 parent 7acd76f commit 560c2be
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/rust/driver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ tonic-build = "0.12.0"

[patch.crates-io]
# Waiting on the next release of Onig crate
sysinfo = { git = "https://github.com/you54f/sysinfo", default-features = false, branch = "feat/windows_tree_kill" }
sysinfo = { git = "https://github.com/you54f/sysinfo", branch = "feat/windows_tree_kill" }
4 changes: 2 additions & 2 deletions drivers/rust/driver/src/child_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::time::Duration;

use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use sysinfo::{Pid, Signal, System};
use sysinfo::{Pid, ProcessesToUpdate, Signal, System};
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::Child;
use tracing::{debug, error, trace, warn};
Expand Down Expand Up @@ -109,7 +109,7 @@ impl ChildPluginProcess {
/// Kill the running plugin process
pub fn kill(&self) {
let mut s = System::new();
s.refresh_processes();
s.refresh_processes(ProcessesToUpdate::All);
if let Some(process) = s.process(Pid::from_u32(self.child_pid as u32)) {
process.kill_with(Signal::Term);
} else {
Expand Down
4 changes: 2 additions & 2 deletions drivers/rust/driver/src/child_process_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::time::Duration;

use anyhow::anyhow;
use serde::{Deserialize, Serialize};
use sysinfo::{Pid, System};
use sysinfo::{Pid, ProcessesToUpdate, System};
use tracing::{debug, error, trace, warn};

use crate::plugin_models::PactPluginManifest;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl ChildPluginProcess {
/// Kill the running plugin process
pub fn kill(&self) {
let mut s = System::new();
s.refresh_processes();
s.refresh_processes(ProcessesToUpdate::All);
if let Some(process) = s.process(Pid::from_u32(self.child_pid as u32)) {
process.kill();
} else {
Expand Down
7 changes: 4 additions & 3 deletions drivers/rust/driver/src/plugin_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use pact_models::v4::interaction::V4Interaction;
use reqwest::Client;
use semver::Version;
use serde_json::Value;
use sysinfo::{Pid,System};
use sysinfo::{ProcessesToUpdate, Pid, System};
#[cfg(not(windows))] use sysinfo::Signal;
#[cfg(not(windows))] use tokio::process::Command;
use tracing::{debug, info, trace, warn};
Expand Down Expand Up @@ -246,6 +246,7 @@ pub async fn init_handshake(manifest: &PactPluginManifest, plugin: &mut (dyn Pac

#[cfg(not(windows))]
async fn start_plugin_process(manifest: &PactPluginManifest) -> anyhow::Result<PactPlugin> {

debug!("Starting plugin with manifest {:?}", manifest);

let os_info = os_info::get();
Expand Down Expand Up @@ -287,7 +288,7 @@ async fn start_plugin_process(manifest: &PactPluginManifest) -> anyhow::Result<P
Ok(child) => Ok(PactPlugin::new(manifest, child)),
Err(err) => {
let mut s = System::new();
s.refresh_processes();
s.refresh_processes(ProcessesToUpdate::All);
if let Some(process) = s.process(Pid::from_u32(child_pid)) {
process.kill_with(Signal::Term);
} else {
Expand Down Expand Up @@ -336,7 +337,7 @@ async fn start_plugin_process(manifest: &PactPluginManifest) -> anyhow::Result<P
Ok(child) => Ok(PactPlugin::new(manifest, child)),
Err(err) => {
let mut s = System::new();
s.refresh_processes();
s.refresh_processes(ProcessesToUpdate::All);
if let Some(process) = s.process(Pid::from_u32(child_pid)) {
process.kill();
} else {
Expand Down

0 comments on commit 560c2be

Please sign in to comment.