Merge branch 'ab/prettyping'
[liboping.git] / src / oping.c
index 5c0ead5..b3beeb0 100644 (file)
@@ -128,6 +128,10 @@ static size_t const hist_colors_num = sizeof (hist_colors_utf8)
 # define _POSIX_SAVED_IDS 0
 #endif
 
+#ifndef IPTOS_MINCOST
+# define IPTOS_MINCOST 0x02
+#endif
+
 /* Remove GNU specific __attribute__ settings when using another compiler */
 #if !__GNUC__
 # define __attribute__(x) /**/
@@ -1402,7 +1406,12 @@ int main (int argc, char **argv) /* {{{ */
                        return (1);
                }
 
-               if (ping_send (ping) < 0)
+               status = ping_send (ping);
+               if (status == -EINTR)
+               {
+                       continue;
+               }
+               else if (status < 0)
                {
                        fprintf (stderr, "ping_send failed: %s\n",
                                        ping_get_error (ping));
@@ -1435,14 +1444,13 @@ int main (int argc, char **argv) /* {{{ */
                /* printf ("Sleeping for %i.%09li seconds\n", (int) ts_wait.tv_sec, ts_wait.tv_nsec); */
                while ((status = nanosleep (&ts_wait, &ts_wait)) != 0)
                {
-                       if (errno != EINTR)
+                       if (errno == EINTR)
                        {
-                               perror ("nanosleep");
-                               break;
+                               continue;
                        }
-                       else if (opt_count == 0)
+                       else
                        {
-                               /* sigint */
+                               perror ("nanosleep");
                                break;
                        }
                }