Skip to content

Commit 9d523b6

Browse files
author
Jacob Hageman
committed
Fix #120, Exit console loop on shutdown
1 parent 9d5034d commit 9d523b6

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/os/posix/src/os-impl-console.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
#include "os-shared-idmap.h"
3636
#include "os-shared-printf.h"
37+
#include "os-shared-common.h"
3738

3839
/*
3940
* By default the console output is always asynchronous
@@ -96,7 +97,9 @@ static void *OS_ConsoleTask_Entry(void *arg)
9697
if (OS_ObjectIdGetById(OS_LOCK_MODE_REFCOUNT, OS_OBJECT_TYPE_OS_CONSOLE, local_arg.id, &token) == OS_SUCCESS)
9798
{
9899
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
99-
while (true)
100+
101+
/* Loop forever (unless shutdown is set) */
102+
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
100103
{
101104
OS_ConsoleOutput_Impl(&token);
102105
sem_wait(&local->data_sem);

src/os/rtems/src/os-impl-console.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "os-rtems.h"
3939
#include "os-shared-printf.h"
4040
#include "os-shared-idmap.h"
41+
#include "os-shared-common.h"
4142

4243
/****************************************************************************************
4344
DEFINES
@@ -120,7 +121,9 @@ static void OS_ConsoleTask_Entry(rtems_task_argument arg)
120121
OS_SUCCESS)
121122
{
122123
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
123-
while (true)
124+
125+
/* Loop forever (unless shutdown is set) */
126+
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
124127
{
125128
OS_ConsoleOutput_Impl(&token);
126129
rtems_semaphore_obtain(local->data_sem, RTEMS_WAIT, RTEMS_NO_TIMEOUT);

src/os/vxworks/src/os-impl-console.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include "os-shared-printf.h"
3535
#include "os-shared-idmap.h"
36+
#include "os-shared-common.h"
3637

3738
/****************************************************************************************
3839
DEFINES
@@ -104,7 +105,9 @@ int OS_VxWorks_ConsoleTask_Entry(int arg)
104105
OS_SUCCESS)
105106
{
106107
local = OS_OBJECT_TABLE_GET(OS_impl_console_table, token);
107-
while (true)
108+
109+
/* Loop forever (unless shutdown is set) */
110+
while (OS_SharedGlobalVars.ShutdownFlag != OS_SHUTDOWN_MAGIC_NUMBER)
108111
{
109112
OS_ConsoleOutput_Impl(&token);
110113
if (semTake(local->datasem, WAIT_FOREVER) == ERROR)

0 commit comments

Comments
 (0)