Skip to content

Commit 2fcb0ad

Browse files
committed
Clear SIGRESUME (SIGUSR1) when exiting xPortStartScheduler
1 parent 78e0cc7 commit 2fcb0ad

File tree

1 file changed

+30
-0
lines changed
  • portable/ThirdParty/GCC/Posix

1 file changed

+30
-0
lines changed

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,33 @@ void vPortStartFirstTask( void )
202202
}
203203
/*-----------------------------------------------------------*/
204204

205+
/*
206+
* Clear a signal that is pending for the calling thread.
207+
*/
208+
void prvClearPendingSignal( int sig )
209+
{
210+
sigset_t set, oldset;
211+
212+
/* Block the signal */
213+
sigemptyset( &set );
214+
sigaddset( &set, sig );
215+
pthread_sigmask( SIG_BLOCK, &set, &oldset );
216+
217+
/* Check if signal is pending */
218+
sigpending( &set );
219+
220+
if( sigismember( &set, sig ) )
221+
{
222+
int signum;
223+
/* Wait for and remove signal */
224+
sigwait( &set, &signum );
225+
}
226+
227+
/* Restore the original signal mask */
228+
pthread_sigmask( SIG_SETMASK, &oldset, NULL );
229+
}
230+
/*-----------------------------------------------------------*/
231+
205232
/*
206233
* See header file for description.
207234
*/
@@ -250,6 +277,9 @@ BaseType_t xPortStartScheduler( void )
250277
hSigSetupThread = PTHREAD_ONCE_INIT;
251278
#endif /* __APPLE__*/
252279

280+
// Clear SIG_RESUME (SIGUSR1), because it might have fired again while we were shutting things down.
281+
prvClearPendingSignal( SIG_RESUME );
282+
253283
/* Restore original signal mask. */
254284
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
255285

0 commit comments

Comments
 (0)