signal handler setup
This commit is contained in:
parent
30cfdf6783
commit
919e00dd88
15
websh.c
15
websh.c
@ -24,6 +24,13 @@ static int sFlag = 0;
|
|||||||
static const char *word;
|
static const char *word;
|
||||||
static const char *tag;
|
static const char *tag;
|
||||||
|
|
||||||
|
volatile sig_atomic_t quit = 0;
|
||||||
|
|
||||||
|
static void handle_signal(int signal)
|
||||||
|
{
|
||||||
|
quit = 1;
|
||||||
|
}
|
||||||
|
|
||||||
void usage(void)
|
void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Usage: websh [-e] [-h] [-s WORD:TAG]\n");
|
fprintf(stderr, "Usage: websh [-e] [-h] [-s WORD:TAG]\n");
|
||||||
@ -93,5 +100,13 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
parse(argc, argv);
|
parse(argc, argv);
|
||||||
|
|
||||||
|
struct sigaction sa;
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = handle_signal;
|
||||||
|
sigaction(SIGINT, &sa, NULL);
|
||||||
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user