From 60417e2d91a7beabc1bb62bf2e8abc7959845e3e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 12 Jul 2016 13:58:09 +0300 Subject: [PATCH] Bail if an error occurs on startup --- main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 00b26de..dbc1619 100644 --- a/main.c +++ b/main.c @@ -135,17 +135,23 @@ int main(int argc, char **argv) if(monitor.interface_name) { - monitor_init(&monitor); + if(monitor_init(&monitor)) + return 1; if(trigger.command) - trigger_init(&trigger); + if(trigger_init(&trigger)) + return 1; } if(pinger.target_name) - pinger_init(&pinger); + if(pinger_init(&pinger)) + return 1; if(!no_daemon && daemon(1, 0)==-1) + { perror("daemon"); + return 1; + } openlog("netmon", 0, LOG_LOCAL7); @@ -417,7 +423,7 @@ int pinger_init(Pinger *pinger) pinger->socket = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP); if(pinger->socket==-1) { - perror("socket"); + perror("socket(SOCK_RAW)"); return -1; } -- 2.45.2