Make absolutely sure subprocess is not killed #14

Merged
eNV25 merged 2 commits from pr/process_group into main 2024-05-20 21:06:27 +02:00
3 changed files with 8 additions and 6 deletions
Showing only changes of commit 4c86e55aea - Show all commits

View file

@ -1,7 +1,8 @@
use std::env; use std::env;
use std::io; use std::io;
use std::process; use std::process;
use serde_json::{self, json};
use serde_json::json;
use crate::browser; use crate::browser;
use crate::config::Config; use crate::config::Config;
@ -94,7 +95,7 @@ impl Command {
// NOTE: On Windows, browser spawns process into a Job object. // NOTE: On Windows, browser spawns process into a Job object.
// NOTE: We need to detach player from the job, so it won't get killed after we're done, // NOTE: We need to detach player from the job, so it won't get killed after we're done,
// NOTE: See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#closing_the_native_app // NOTE: See https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_messaging#closing_the_native_app
#[cfg(target_family = "windows")] #[cfg(windows)]
{ {
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
const CREATE_BREAKAWAY_FROM_JOB: u32 = 0x01000000; const CREATE_BREAKAWAY_FROM_JOB: u32 = 0x01000000;

View file

@ -1,6 +1,7 @@
use std::env; use std::env;
use std::fs; use std::fs;
use std::path::PathBuf; use std::path::PathBuf;
use serde::Deserialize; use serde::Deserialize;
use crate::error::FF2MpvError; use crate::error::FF2MpvError;
@ -16,7 +17,7 @@ impl Default for Config {
fn default() -> Self { fn default() -> Self {
Self { Self {
player_command: "mpv".to_owned(), player_command: "mpv".to_owned(),
player_args: vec![] player_args: vec![],
} }
} }
} }
@ -40,7 +41,7 @@ impl Config {
Ok(config) Ok(config)
} }
#[cfg(target_family = "unix")] #[cfg(unix)]
fn get_config_location() -> PathBuf { fn get_config_location() -> PathBuf {
let mut path = PathBuf::new(); let mut path = PathBuf::new();
@ -57,7 +58,7 @@ impl Config {
path path
} }
#[cfg(target_family = "windows")] #[cfg(windows)]
fn get_config_location() -> PathBuf { fn get_config_location() -> PathBuf {
let mut path = PathBuf::new(); let mut path = PathBuf::new();
let appdata = env::var("APPDATA").unwrap(); let appdata = env::var("APPDATA").unwrap();

View file

@ -1,6 +1,6 @@
use std::io;
use std::fmt; use std::fmt;
use std::fmt::Display; use std::fmt::Display;
use std::io;
pub enum FF2MpvError { pub enum FF2MpvError {
NoConfig, NoConfig,