Skip to content

Commit 94263d2

Browse files
committed
Simpler, more targeted solution
1 parent 0e644d3 commit 94263d2

File tree

1 file changed

+11
-31
lines changed
  • portable/ThirdParty/GCC/Posix

1 file changed

+11
-31
lines changed

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -260,39 +260,12 @@ void vPortStartFirstTask( void )
260260
}
261261
/*-----------------------------------------------------------*/
262262

263-
/*
264-
* Clear a signal that is pending for the calling thread.
265-
*/
266-
void prvClearPendingSignal( int sig )
267-
{
268-
sigset_t set, oldset;
269-
270-
/* Block the signal */
271-
sigemptyset( &set );
272-
sigaddset( &set, sig );
273-
pthread_sigmask( SIG_BLOCK, &set, &oldset );
274-
275-
/* Check if signal is pending */
276-
sigpending( &set );
277-
278-
if( sigismember( &set, sig ) )
279-
{
280-
int signum;
281-
/* Wait for and remove signal */
282-
sigwait( &set, &signum );
283-
}
284-
285-
/* Restore the original signal mask */
286-
pthread_sigmask( SIG_SETMASK, &oldset, NULL );
287-
}
288-
/*-----------------------------------------------------------*/
289-
290263
/*
291264
* See header file for description.
292265
*/
293266
BaseType_t xPortStartScheduler( void )
294267
{
295-
int iSignal;
268+
int iSignal = 0;
296269
sigset_t xSignals;
297270

298271
hMainThread = pthread_self();
@@ -318,6 +291,16 @@ BaseType_t xPortStartScheduler( void )
318291
while( xSchedulerEnd != pdTRUE )
319292
{
320293
sigwait( &xSignals, &iSignal );
294+
295+
/* For some reason, sigwait() doesn't always clear the signal the first time.
296+
* Clear it again if it's still pending.
297+
*/
298+
sigset_t set;
299+
sigpending( &set );
300+
if( sigismember( &set, SIG_RESUME ) )
301+
{
302+
sigwait( &xSignals, &iSignal );
303+
}
321304
}
322305

323306
/*
@@ -335,9 +318,6 @@ BaseType_t xPortStartScheduler( void )
335318
hSigSetupThread = PTHREAD_ONCE_INIT;
336319
#endif /* __APPLE__*/
337320

338-
// Clear SIG_RESUME (SIGUSR1), because it might have fired again while we were shutting things down.
339-
prvClearPendingSignal( SIG_RESUME );
340-
341321
/* Restore original signal mask. */
342322
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
343323

0 commit comments

Comments
 (0)