linguini1 opened a new issue, #20163:
URL: https://github.com/apache/nuttx/issues/20163

   ### Is your feature request related to a problem? Please describe.
   
   Currently, the NuttX implementation of the pthread library does not 
implement `pthread_sigqueue`.
   
   This function is used to queue a signal and data to a thread, which can be 
useful for cancelling a thread/doing operations to it without using 
`pthread_cancel`.
   
   ### Describe the solution you'd like
   
   I noticed that `sigqueue` on NuttX takes a "task ID" as its first parameter. 
According to the output of `ps` (at least on one system, the ESP32C3), both 
processes and their threads are given unique task IDs on NuttX. Since the NuttX 
implementation of `pthread_create` returns the task ID in `pthread_t`, I think 
we can just pass `pthread_t` directly to `sigqueue`.
   
   My suggestion is that we implement `pthread_sigqueue` as follows:
   ```c
   #define pthread_sigqueue(thread, sig, value) sigqueue(thread, sig, value)
   ```
   This may possibly need some `ifdefs` in case there is any scenario where 
`sigqueue` is not an exposed symbol (i.e. the user has disabled POSIX signals 
on NuttX). This will work since the interface and behaviour of the two 
functions is identical from what I can tell in the man pages.
   
   I'm not sure if I'm missing a reason that this function was not implemented, 
but if there is something I'm overlooking please let me know.
   
   ### Describe alternatives you've considered
   
   Another alternative is to implement a stub, just to make porting easier. 
`pthread_sigqueue` says on its manpage it can return `ENOSYS` if the function 
is not supported on the system. This may be a good alternative if there's some 
fundamental reason we can't implement it; at least complex applications being 
ported can use that to determine they need to have a fallback approach to 
queuing signals.
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
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