set ^C handler just before writing samples and rely on default action to terminate the process when waiting a matching subscriber
Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
bb92294f4e
commit
d1c5cd9b57
1 changed files with 11 additions and 11 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue