Skip to content

Commit

Permalink
Fix nasa#120, Exit console loop on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Dec 2, 2020
1 parent fa0cffa commit 2739d25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/os/posix/src/os-impl-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "os-impl-console.h"

#include "os-shared-printf.h"
#include "os-shared-common.h"

/*
* By default the console output is always asynchronous
Expand Down Expand Up @@ -90,7 +91,9 @@ static void *OS_ConsoleTask_Entry(void *arg)

local_arg.opaque_arg = arg;
local = &OS_impl_console_table[local_arg.idx];
while (true)

/* Loop forever (unless shutdown is set) */
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
{
OS_ConsoleOutput_Impl(local_arg.idx);
sem_wait(&local->data_sem);
Expand Down
5 changes: 4 additions & 1 deletion src/os/rtems/src/os-impl-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "os-rtems.h"
#include "os-shared-printf.h"
#include "os-shared-idmap.h"
#include "os-shared-common.h"

/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -115,7 +116,9 @@ static void OS_ConsoleTask_Entry(rtems_task_argument arg)
OS_impl_console_internal_record_t *local;

local = &OS_impl_console_table[local_id];
while (true)

/* Loop forever (unless shutdown is set) */
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
{
OS_ConsoleOutput_Impl(local_id);
rtems_semaphore_obtain(local->data_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
Expand Down
5 changes: 4 additions & 1 deletion src/os/vxworks/src/os-impl-console.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "os-impl-console.h"

#include "os-shared-printf.h"
#include "os-shared-common.h"

/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -98,7 +99,9 @@ int OS_VxWorks_ConsoleTask_Entry(int arg)
OS_impl_console_internal_record_t *local;

local = &OS_impl_console_table[local_id];
while (true)

/* Loop forever (unless shutdown is set or semTake fails) */
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
{
OS_ConsoleOutput_Impl(local_id);
if (semTake(local->datasem, WAIT_FOREVER) == ERROR)
Expand Down

0 comments on commit 2739d25

Please sign in to comment.