Tests: cleanly exit from test apps on reception of SIGTERM
[lttng-tools.git] / tests / utils / testapp / gen-ust-tracef / gen-ust-tracef.c
index 1c3493dba3c003c86094ab6d009278ec67d89909..971bfd8d16a5f6d82de2481a5657f7a19c6db1b5 100644 (file)
@@ -16,6 +16,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#define _LGPL_SOURCE
 #include <assert.h>
 #include <fcntl.h>
 #include <stdarg.h>
@@ -28,6 +29,7 @@
 #include <unistd.h>
 
 #include <lttng/tracef.h>
+#include "signal-helper.h"
 
 const char *str = "test string";
 
@@ -53,6 +55,10 @@ int main(int argc, char **argv)
        useconds_t nr_usec = 0;
        char *tmp_file_path = NULL;
 
+       if (set_signal_handler()) {
+               return 1;
+       }
+
        if (argc >= 2) {
                nr_iter = atoi(argv[1]);
        }
@@ -77,6 +83,9 @@ int main(int argc, char **argv)
                        create_file(tmp_file_path);
                }
                usleep(nr_usec);
+               if (should_quit) {
+                       break;
+               }
        }
 
        return 0;
This page took 0.026126 seconds and 5 git commands to generate.