Break out of the main loop on Control-C.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
2b819b6b76
commit
889c707ba1
20
ptp4l.c
20
ptp4l.c
|
@ -17,6 +17,7 @@
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -76,6 +77,12 @@ static struct config cfg_settings = {
|
||||||
.cfg_ignore = 0,
|
.cfg_ignore = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void handle_int_quit_term(int s)
|
||||||
|
{
|
||||||
|
pr_notice("caught signal %d", s);
|
||||||
|
running = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void usage(char *progname)
|
static void usage(char *progname)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -122,6 +129,19 @@ int main(int argc, char *argv[])
|
||||||
struct defaultDS *ds = &cfg_settings.dds;
|
struct defaultDS *ds = &cfg_settings.dds;
|
||||||
int phc_index = -1;
|
int phc_index = -1;
|
||||||
|
|
||||||
|
if (SIG_ERR == signal(SIGINT, handle_int_quit_term)) {
|
||||||
|
fprintf(stderr, "cannot handle SIGINT\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (SIG_ERR == signal(SIGQUIT, handle_int_quit_term)) {
|
||||||
|
fprintf(stderr, "cannot handle SIGQUIT\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (SIG_ERR == signal(SIGTERM, handle_int_quit_term)) {
|
||||||
|
fprintf(stderr, "cannot handle SIGTERM\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Process the command line arguments. */
|
/* Process the command line arguments. */
|
||||||
progname = strrchr(argv[0], '/');
|
progname = strrchr(argv[0], '/');
|
||||||
progname = progname ? 1+progname : argv[0];
|
progname = progname ? 1+progname : argv[0];
|
||||||
|
|
Loading…
Reference in New Issue