casaroli opened a new pull request, #20720:
URL: https://github.com/apache/nuttx/pull/20720

   ## Summary
   
   `pselect()`, `ppoll()` and `sigsuspend()` install a temporary signal mask 
and restore the old one before they return. In a system call, a signal that the 
temporary mask unblocks is not delivered at once: it goes back on the pending 
list, to be dispatched at the end of the system call. By then the old mask was 
restored, so a signal that the old mask blocks stayed pending and its handler 
never ran; every later `pselect()` returned `EINTR` at once.
   
   In a system call, the temporary mask now stays and the old one is saved in 
the TCB. `nxsig_unmask_pendingsignal()`, at the end of the system call, 
dispatches the pending signals with the temporary mask and then restores the 
old mask. Outside a system call the mask is restored at once, as before.
   
   ## Impact
   
   Kernel builds (`pselect()` etc. as system calls): the handler of a signal 
unblocked only by the temporary mask now runs once. Flat builds behave as 
before.
   
   ## Testing
   
   Builds: `qemu-armv8a:nsh`, `qemu-armv8a:knsh`, `lm3s6965-ek:qemu-flat`.
   
   Runtime, QEMU 11 with HVF on an Apple M4: `ostest` on `qemu-armv8a:knsh` 
(kernel build) and `qemu-armv8a:nsh` (flat build) ends with `ostest_main: 
Exiting with status 0`.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   
   A test program on `qemu-armv8a:knsh`: block `SIGUSR1`, raise it, then call 
`pselect()` three times with an empty mask and a 200 ms timeout.
   
   master:
   ```
   pseltest: pselect 0 returned -1 (Interrupted system call), handler ran 0 
times
   pseltest: pselect 1 returned -1 (Interrupted system call), handler ran 0 
times
   pseltest: pselect 2 returned -1 (Interrupted system call), handler ran 0 
times
   pseltest: FAIL
   ```
   
   This PR:
   ```
   pseltest: pselect 0 returned -1 (Interrupted system call), handler ran 1 
times
   pseltest: pselect 1 returned 0 (timeout), handler ran 1 times
   pseltest: pselect 2 returned 0 (timeout), handler ran 1 times
   pseltest: PASS
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to