]> git.tdb.fi Git - netmon.git/commitdiff
Bail if an error occurs on startup
authorMikko Rasa <tdb@tdb.fi>
Tue, 12 Jul 2016 10:58:09 +0000 (13:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 12 Jul 2016 10:58:09 +0000 (13:58 +0300)
main.c

diff --git a/main.c b/main.c
index 00b26de58677ed0e6f844bc89710e0916af3980a..dbc1619de9dd8b15f9698657fc420a821619c0b7 100644 (file)
--- 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;
        }