Skip to content

Commit

Permalink
Merge pull request #667 from skliper/fix120-forever-loop
Browse files Browse the repository at this point in the history
Fix #120, Exit console loop on shutdown
  • Loading branch information
astrogeco committed Dec 9, 2020
2 parents 9d5034d + 9d523b6 commit d2d9882
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 @@ -34,6 +34,7 @@

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

/*
* By default the console output is always asynchronous
Expand Down Expand Up @@ -96,7 +97,9 @@ static void *OS_ConsoleTask_Entry(void *arg)
if (OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_CONSOLE, local_arg.id, &token) == OS_SUCCESS)
{
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
while (true)

/* Loop forever (unless shutdown is set) */
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
{
OS_ConsoleOutput_Impl(&token);
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 @@ -120,7 +121,9 @@ static void OS_ConsoleTask_Entry(rtems_task_argument arg)
OS_SUCCESS)
{
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
while (true)

/* Loop forever (unless shutdown is set) */
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
{
OS_ConsoleOutput_Impl(&token);
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 @@ -33,6 +33,7 @@

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

/****************************************************************************************
DEFINES
Expand Down Expand Up @@ -104,7 +105,9 @@ int OS_VxWorks_ConsoleTask_Entry(int arg)
OS_SUCCESS)
{
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
while (true)

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

0 comments on commit d2d9882

Please sign in to comment.