-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abort plugin if specific signal received
- Loading branch information
Showing
7 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "shadowsocks-rust" | ||
version = "1.6.0" | ||
version = "1.6.1" | ||
authors = ["Y. T. CHUNG <[email protected]>"] | ||
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls." | ||
repository = "https://github.com/zonyitoo/shadowsocks-rust" | ||
|
@@ -59,3 +59,6 @@ url = "1.5" | |
[dependencies.sodiumoxide] | ||
version = "0.0.15" | ||
optional = true | ||
|
||
[target.'cfg(unix)'.dependencies] | ||
tokio-signal = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::io; | ||
|
||
use libc; | ||
use tokio_core::reactor::Handle; | ||
|
||
use futures::{Future, Stream}; | ||
|
||
#[cfg(unix)] | ||
pub fn monitor_signal(handle: &Handle) { | ||
use tokio_signal::unix::Signal; | ||
|
||
let fut = Signal::new(libc::SIGCHLD, handle) | ||
.and_then(|signal| { | ||
signal.for_each(|_| -> Result<(), io::Error> { | ||
panic!("Plugin exited unexpectly (SIGCHLD)"); | ||
}) | ||
}) | ||
.map_err(|err| { | ||
error!("Failed to monitor SIGCHLD, err: {:?}", err); | ||
}); | ||
|
||
handle.spawn(fut); | ||
|
||
let fut = Signal::new(libc::SIGTERM, handle) | ||
.and_then(|sigterm| { | ||
sigterm.for_each(|_| -> Result<(), io::Error> { | ||
panic!("Received SIGTERM, aborting process"); | ||
}) | ||
}) | ||
.map_err(|err| { | ||
error!("Failed to monitor SIGTERM, SIGINT, err: {:?}", err); | ||
}); | ||
|
||
handle.spawn(fut); | ||
} | ||
|
||
#[cfg(not(unix))] | ||
pub fn monitor_signal(handle: &Handle) { | ||
// FIXME: Do nothing ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters