@@ -260,39 +260,12 @@ void vPortStartFirstTask( void )
260
260
}
261
261
/*-----------------------------------------------------------*/
262
262
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
-
290
263
/*
291
264
* See header file for description.
292
265
*/
293
266
BaseType_t xPortStartScheduler ( void )
294
267
{
295
- int iSignal ;
268
+ int iSignal = 0 ;
296
269
sigset_t xSignals ;
297
270
298
271
hMainThread = pthread_self ();
@@ -318,6 +291,16 @@ BaseType_t xPortStartScheduler( void )
318
291
while ( xSchedulerEnd != pdTRUE )
319
292
{
320
293
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
+ int result = sigwait ( & xSignals , & iSignal );
303
+ }
321
304
}
322
305
323
306
/*
@@ -335,9 +318,6 @@ BaseType_t xPortStartScheduler( void )
335
318
hSigSetupThread = PTHREAD_ONCE_INIT ;
336
319
#endif /* __APPLE__*/
337
320
338
- // Clear SIG_RESUME (SIGUSR1), because it might have fired again while we were shutting things down.
339
- prvClearPendingSignal ( SIG_RESUME );
340
-
341
321
/* Restore original signal mask. */
342
322
( void ) pthread_sigmask ( SIG_SETMASK , & xSchedulerOriginalSignalMask , NULL );
343
323
0 commit comments