mirror of
https://github.com/dennypage/dpinger.git
synced 2024-05-19 06:50:01 +00:00
Log signal number on exit
This commit is contained in:
45
dpinger.c
45
dpinger.c
@@ -1,6 +1,6 @@
|
||||
|
||||
//
|
||||
// Copyright (c) 2015-2020, Denny Page
|
||||
// Copyright (c) 2015-2022, Denny Page
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
@@ -190,25 +190,6 @@ static uint16_t sequence_limit;
|
||||
// Receive thread ready
|
||||
static unsigned int recv_ready = 0;
|
||||
|
||||
//
|
||||
// Termination handler
|
||||
//
|
||||
__attribute__ ((noreturn))
|
||||
static void
|
||||
term_handler(void)
|
||||
{
|
||||
// NB: This function may be simultaneously invoked by multiple threads
|
||||
if (usocket_name)
|
||||
{
|
||||
(void) unlink(usocket_name);
|
||||
}
|
||||
if (pidfile_name)
|
||||
{
|
||||
(void) unlink(pidfile_name);
|
||||
}
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Log for abnormal events
|
||||
@@ -234,6 +215,28 @@ logger(
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Termination handler
|
||||
//
|
||||
__attribute__ ((noreturn))
|
||||
static void
|
||||
term_handler(
|
||||
int signum)
|
||||
{
|
||||
// NB: This function may be simultaneously invoked by multiple threads
|
||||
if (usocket_name)
|
||||
{
|
||||
(void) unlink(usocket_name);
|
||||
}
|
||||
if (pidfile_name)
|
||||
{
|
||||
(void) unlink(pidfile_name);
|
||||
}
|
||||
logger("exiting on signal %d\n", signum);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Compute checksum for ICMP
|
||||
//
|
||||
@@ -840,7 +843,7 @@ get_length_arg(
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr, "Dpinger version 3.1\n\n");
|
||||
fprintf(stderr, "Dpinger version 3.2\n\n");
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s [-f] [-R] [-S] [-P] [-B bind_addr] [-s send_interval] [-l loss_interval] [-t time_period] [-r report_interval] [-d data_length] [-o output_file] [-A alert_interval] [-D latency_alarm] [-L loss_alarm] [-C alert_cmd] [-i identifier] [-u usocket] [-p pidfile] dest_addr\n\n", progname);
|
||||
fprintf(stderr, " options:\n");
|
||||
|
||||
Reference in New Issue
Block a user