New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bin: handle TERM/INT signal #1058
Conversation
break; | ||
} | ||
// TODO: handle more signal | ||
_ => debug!("ignore signal: {}", sig), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/debug/warn/
fn handle_signal(ch: SendCh<Msg>) { | ||
use signal::trap::Trap; | ||
use nix::sys::signal::{SIGTERM, SIGINT}; | ||
let trap = Trap::trap(&[SIGTERM, SIGINT]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will block until receiving a signal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the for loop below will block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't find any doc or example how trap should be used.
Will it rerun this piece of signal catching code if the specified signal happens? Like a callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs: https://tailhook.github.io/signal/signal/trap/index.html
Examples: https://github.com/tailhook/signal/tree/master/examples
It use sigwait
internally, see also http://man7.org/linux/man-pages/man3/sigwait.3.html
LGTM |
PTAL |
LGTM |
…1058) Signed-off-by: Ping Yu <yuping@pingcap.com>
ref: #1053