diff --git a/src/examples/throughput/publisher.c b/src/examples/throughput/publisher.c index b8b049d..f1606c7 100644 --- a/src/examples/throughput/publisher.c +++ b/src/examples/throughput/publisher.c @@ -57,17 +57,6 @@ int main (int argc, char **argv) dds_entity_t writer; ThroughputModule_DataType sample; - /* Register handler for Ctrl-C */ -#ifdef _WIN32 - SetConsoleCtrlHandler ((PHANDLER_ROUTINE) CtrlHandler, true); -#else - struct sigaction sat; - sat.sa_handler = CtrlHandler; - sigemptyset (&sat.sa_mask); - sat.sa_flags = 0; - sigaction (SIGINT, &sat, &oldAction); -#endif - if (parse_args(argc, argv, &payloadSize, &burstInterval, &burstSize, &timeOut, &partitionName) == EXIT_FAILURE) { return EXIT_FAILURE; } @@ -90,6 +79,17 @@ int main (int argc, char **argv) sample.payload._buffer[i] = 'a'; } + /* Register handler for Ctrl-C */ +#ifdef _WIN32 + SetConsoleCtrlHandler ((PHANDLER_ROUTINE) CtrlHandler, true); +#else + struct sigaction sat; + sat.sa_handler = CtrlHandler; + sigemptyset (&sat.sa_mask); + sat.sa_flags = 0; + sigaction (SIGINT, &sat, &oldAction); +#endif + /* Register the sample instance and write samples repeatedly or until time out */ start_writing(writer, &sample, burstInterval, burstSize, timeOut);