forked from epagris/FreeRTOS-Kernel
		
	Block SIG_RESUME in the main thread of the Posix port so that sigwait works as expected (#532)
Co-authored-by: alfred gedeon <28123637+alfred2g@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									4a8c06689e
								
							
						
					
					
						commit
						fc615627f6
					
				
							
								
								
									
										25
									
								
								portable/ThirdParty/GCC/Posix/port.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								portable/ThirdParty/GCC/Posix/port.c
									
									
									
									
										vendored
									
									
								
							@ -191,13 +191,19 @@ portBASE_TYPE xPortStartScheduler( void )
 | 
			
		||||
     * Interrupts are disabled here already. */
 | 
			
		||||
    prvSetupTimerInterrupt();
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Block SIG_RESUME before starting any tasks so the main thread can sigwait on it.
 | 
			
		||||
     * To sigwait on an unblocked signal is undefined.
 | 
			
		||||
     * https://pubs.opengroup.org/onlinepubs/009604499/functions/sigwait.html
 | 
			
		||||
     */
 | 
			
		||||
    sigemptyset( &xSignals );
 | 
			
		||||
    sigaddset( &xSignals, SIG_RESUME );
 | 
			
		||||
    ( void ) pthread_sigmask( SIG_BLOCK, &xSignals, NULL );
 | 
			
		||||
 | 
			
		||||
    /* Start the first task. */
 | 
			
		||||
    vPortStartFirstTask();
 | 
			
		||||
 | 
			
		||||
    /* Wait until signaled by vPortEndScheduler(). */
 | 
			
		||||
    sigemptyset( &xSignals );
 | 
			
		||||
    sigaddset( &xSignals, SIG_RESUME );
 | 
			
		||||
 | 
			
		||||
    while( xSchedulerEnd != pdTRUE )
 | 
			
		||||
    {
 | 
			
		||||
        sigwait( &xSignals, &iSignal );
 | 
			
		||||
@ -543,23 +549,10 @@ static void prvSetupSignalsAndSchedulerPolicy( void )
 | 
			
		||||
                              &xAllSignals,
 | 
			
		||||
                              &xSchedulerOriginalSignalMask );
 | 
			
		||||
 | 
			
		||||
    /* SIG_RESUME is only used with sigwait() so doesn't need a
 | 
			
		||||
     * handler. */
 | 
			
		||||
    sigresume.sa_flags = 0;
 | 
			
		||||
    sigresume.sa_handler = SIG_IGN;
 | 
			
		||||
    sigfillset( &sigresume.sa_mask );
 | 
			
		||||
 | 
			
		||||
    sigtick.sa_flags = 0;
 | 
			
		||||
    sigtick.sa_handler = vPortSystemTickHandler;
 | 
			
		||||
    sigfillset( &sigtick.sa_mask );
 | 
			
		||||
 | 
			
		||||
    iRet = sigaction( SIG_RESUME, &sigresume, NULL );
 | 
			
		||||
 | 
			
		||||
    if( iRet == -1 )
 | 
			
		||||
    {
 | 
			
		||||
        prvFatalError( "sigaction", errno );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    iRet = sigaction( SIGALRM, &sigtick, NULL );
 | 
			
		||||
 | 
			
		||||
    if( iRet == -1 )
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user