Tests: Switch test apps to use usleep_safe()
[lttng-tools.git] / tests / utils / testapp / gen-ust-events / gen-ust-events.c
index f1eb18f52f927cb7ffd6181d11f2d19666768e42..3cfadbe9976a70aa6bdc16240707d49160ca01b0 100644 (file)
@@ -31,6 +31,7 @@
 #include <signal.h>
 #include <poll.h>
 #include <errno.h>
+#include "utils.h"
 
 #define TRACEPOINT_DEFINE
 #include "tp.h"
@@ -84,7 +85,7 @@ int main(int argc, char **argv)
        char text[10] = "test";
        double dbl = 2.0;
        float flt = 2222.0;
-       int nr_iter = 100;
+       int nr_iter = 100, ret = 0;
        useconds_t nr_usec = 0;
        char *after_first_event_file_path = NULL;
        char *before_last_event_file_path = NULL;
@@ -127,9 +128,13 @@ int main(int argc, char **argv)
                 */
                create_file(after_first_event_file_path);
                if (nr_usec) {
-                       usleep(nr_usec);
+                       if (usleep_safe(nr_usec)) {
+                               ret = -1;
+                               goto end;
+                       }
                }
        }
 
-       return 0;
+end:
+       exit(!ret ? EXIT_SUCCESS : EXIT_FAILURE);
 }
This page took 0.024538 seconds and 5 git commands to generate.