Skip to content

Commit

Permalink
introduce ddsrt_exit
Browse files Browse the repository at this point in the history
  • Loading branch information
poetinger committed Nov 7, 2023
1 parent 43093e4 commit a096afb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/ddsrt/include/dds/ddsrt/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ ddsrt_getprocessname(void);
DDS_EXPORT void
ddsrt_abort(void);

/**
* @brief Performs a normal process termination.
*
* @param status
* @returns The least significant byte of `status` is returned to the parent.
*/
DDS_EXPORT void
ddsrt_exit(int status);

#if defined (__cplusplus)
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions src/ddsrt/src/process/posix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,9 @@ ddsrt_abort(void)
{
abort();
}

void
ddsrt_exit(int status)
{
exit(status);
}
5 changes: 3 additions & 2 deletions src/ddsrt/tests/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "dds/ddsrt/cdtors.h"
#include "dds/ddsrt/retcode.h"
#include "dds/ddsrt/sync.h"
#include "dds/ddsrt/process.h"
#include "dds/ddsrt/threads.h"

static int32_t min_fifo_prio = 250;
Expand Down Expand Up @@ -81,7 +82,7 @@ static uint32_t thread_main(void *ptr)
#elif _WIN32
int prio = GetThreadPriority(GetCurrentThread());
if (prio == THREAD_PRIORITY_ERROR_RETURN)
abort();
ddsrt_abort();
if (prio == attr->schedPriority) {
arg->res = 1;
}
Expand All @@ -92,7 +93,7 @@ static uint32_t thread_main(void *ptr)

err = pthread_getschedparam(pthread_self(), &policy, &sched);
if (err != 0) {
abort();
ddsrt_abort();
}
if (((policy == SCHED_OTHER && attr->schedClass == DDSRT_SCHED_TIMESHARE) ||
(policy == SCHED_FIFO && attr->schedClass == DDSRT_SCHED_REALTIME))
Expand Down
12 changes: 6 additions & 6 deletions src/tools/ddsperf/ddsperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ static void verrorx (int exitcode, const char *fmt, va_list ap)
{
vprintf (fmt, ap);
fflush (stdout);
exit (exitcode);
ddsrt_exit (exitcode);
}

static void error2 (const char *fmt, ...)
Expand Down Expand Up @@ -728,7 +728,7 @@ static uint32_t pubthread (void *varg)
{
printf ("dds_register_instance failed: %d\n", result);
fflush (stdout);
exit (2);
ddsrt_exit (2);
}
}
}
Expand All @@ -751,7 +751,7 @@ static uint32_t pubthread (void *varg)
{
printf ("request loan error: %d\n", result);
fflush (stdout);
exit (2);
ddsrt_exit (2);
}
else
{
Expand All @@ -765,7 +765,7 @@ static uint32_t pubthread (void *varg)
printf ("write error: %d\n", result);
fflush (stdout);
if (result != DDS_RETCODE_TIMEOUT)
exit (2);
ddsrt_exit (2);
/* retry with original timestamp, it really is just a way of reporting
blocking for an exceedingly long time, but do force a fresh time stamp
for the next sample */
Expand Down Expand Up @@ -976,7 +976,7 @@ static int check_eseq (struct eseq_admin *ea, uint32_t seq, uint32_t keyval, uin
if (keyval >= ea->nkeys)
{
printf ("received key %"PRIu32" >= nkeys %u\n", keyval, ea->nkeys);
exit (3);
ddsrt_exit (3);
}
ddsrt_mutex_lock (&ea->lock);
for (uint32_t i = 0; i < ea->nph; i++)
Expand Down Expand Up @@ -1970,7 +1970,7 @@ EXAMPLES:\n\
running for 10s\n\
", argv0, argv0, argv0);
fflush (stdout);
exit (3);
ddsrt_exit (3);
}

struct string_int_map_elem {
Expand Down

0 comments on commit a096afb

Please sign in to comment.