mirror of
https://github.com/watchexec/watchexec.git
synced 2024-09-29 22:51:33 +02:00
No need to use before_exec() to call setpgid()
This commit is contained in:
parent
b16cbec3ee
commit
03775b61ce
@ -8,10 +8,10 @@ env:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
rust: nightly
|
rust: stable
|
||||||
env: TARGET=x86_64-unknown-linux-gnu
|
env: TARGET=x86_64-unknown-linux-gnu
|
||||||
- os: osx
|
- os: osx
|
||||||
rust: nightly
|
rust: stable
|
||||||
env: TARGET=x86_64-apple-darwin
|
env: TARGET=x86_64-apple-darwin
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
@ -22,6 +22,8 @@ Example use cases:
|
|||||||
* By default, uses `.gitignore` to determine which files to ignore notifications for
|
* By default, uses `.gitignore` to determine which files to ignore notifications for
|
||||||
* Support for watching files with a specific extension
|
* Support for watching files with a specific extension
|
||||||
* Support for filtering/ignoring events based on glob patterns
|
* Support for filtering/ignoring events based on glob patterns
|
||||||
|
* Launches child processes in a new process group
|
||||||
|
* Sets `$WATCHEXEC_UPDATED_PATH` in the environment of the child process to the first file that triggered a change
|
||||||
* Optionally clears screen between executions
|
* Optionally clears screen between executions
|
||||||
* Optionally restarts the command with every modification (good for servers)
|
* Optionally restarts the command with every modification (good for servers)
|
||||||
* Does not require a language runtime
|
* Does not require a language runtime
|
||||||
|
@ -3,7 +3,7 @@ environment:
|
|||||||
PROJECT_NAME: watchexec
|
PROJECT_NAME: watchexec
|
||||||
matrix:
|
matrix:
|
||||||
- TARGET: x86_64-pc-windows-gnu
|
- TARGET: x86_64-pc-windows-gnu
|
||||||
CHANNEL: nightly
|
CHANNEL: stable
|
||||||
|
|
||||||
# Install Rust and Cargo
|
# Install Rust and Cargo
|
||||||
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
#![feature(process_exec)]
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate clap;
|
extern crate clap;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use libc;
|
|
||||||
use std::process::{Child, Command};
|
use std::process::{Child, Command};
|
||||||
|
|
||||||
pub struct Runner {
|
pub struct Runner {
|
||||||
@ -33,6 +32,8 @@ impl Runner {
|
|||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn kill(child: &mut Child) {
|
fn kill(child: &mut Child) {
|
||||||
|
use libc;
|
||||||
|
|
||||||
extern {
|
extern {
|
||||||
fn killpg(pgrp: libc::pid_t, sig: libc::c_int) -> libc::c_int;
|
fn killpg(pgrp: libc::pid_t, sig: libc::c_int) -> libc::c_int;
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ impl Runner {
|
|||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn invoke(&self, cmd: &str, updated_paths: Vec<&str>) -> Option<Child> {
|
fn invoke(&self, cmd: &str, updated_paths: Vec<&str>) -> Option<Child> {
|
||||||
use std::os::unix::process::CommandExt;
|
use libc;
|
||||||
|
|
||||||
let mut command = Command::new("sh");
|
let mut command = Command::new("sh");
|
||||||
command.arg("-c").arg(cmd);
|
command.arg("-c").arg(cmd);
|
||||||
@ -65,10 +66,17 @@ impl Runner {
|
|||||||
command.env("WATCHEXEC_UPDATED_PATH", updated_paths[0]);
|
command.env("WATCHEXEC_UPDATED_PATH", updated_paths[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
command
|
let child = command
|
||||||
.before_exec(|| unsafe { libc::setpgid(0, 0); Ok(()) })
|
|
||||||
.spawn()
|
.spawn()
|
||||||
.ok()
|
.ok();
|
||||||
|
|
||||||
|
if let &Some(ref c) = &child {
|
||||||
|
unsafe {
|
||||||
|
libc::setpgid(c.id() as i32, c.id() as i32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
child
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_command(&mut self, cmd: &str, updated_paths: Vec<&str>) {
|
pub fn run_command(&mut self, cmd: &str, updated_paths: Vec<&str>) {
|
||||||
@ -98,6 +106,8 @@ impl Runner {
|
|||||||
|
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
fn wait(child: &mut Child) {
|
fn wait(child: &mut Child) {
|
||||||
|
use libc;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let pid = child.id() as i32;
|
let pid = child.id() as i32;
|
||||||
let status: Box<i32> = Box::new(0);
|
let status: Box<i32> = Box::new(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user