zzby0 commented on PR #16742:
URL: https://github.com/apache/nuttx/pull/16742#issuecomment-3116315589

   > > > > This commit disable interrupts before and after host-APIs, make sure 
that errno is correct.
   > > 
   > > 
   > > the interrupt must be disabled, since many host API can't work well if 
the interrupt happen in side their function.
   > > > i feel this approach is very hard to maintain.
   > > > it's simpler (and probably more efficient) to save/restore errno in 
the "interrupts" instead. what do you think?
   > > 
   > > 
   > > your mean restore errno before enabling interrupt? It doesn't work since 
host main thread manage all nuttx thread and errno will lose if another nuttx 
thread switch in and call some host api which may overwrite the errno value 
before old thread has the chance to retrieve it.
   > 
   > i meant to save/restore in interrupt handlers. as you know, it's a common 
practice for unix to save/restore errno in signal handlers. i don't see any 
reason it doesn't work for sim.
   
   Thanks for the feedback. You're right that saving/restoring errno in 
interrupt handlers is a common Unix practice
   However, here we're dealing with two issues:
   
   1. Errno consistency (which your solution would address well)
   2. Many host APIs lack robust error recovery when interrupted by signals. 
For example, when read() a file is interruped by a signal, it will return error 
directly. (here disable interrupt maybe better)


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