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

   ## Summary
   
   `read()` of an inotify descriptor waits for an event with 
`nxsem_wait_uninterruptible()`. A signal with a handler does not end that wait: 
the handler runs, and `read()` waits again until a file event comes. On Linux, 
the signal ends `read()` with `EINTR`.
   
   This PR waits with `nxsem_wait()`. When a signal ends the wait before an 
event comes, `read()` fails with `EINTR`. The error path was there already: the 
read loop stops at the error and returns it when it copied no event.
   
   ## Impact
   
   `fs/vfs/fs_inotify.c` only, with `CONFIG_FS_NOTIFY`. The same code runs in 
flat, protected and kernel builds; no arch code.
   
   A blocking `read()` of an inotify descriptor can now fail with `EINTR` when 
a signal with a handler comes, as on Linux. No API changes. A non-blocking 
`read()` and `poll()` do not change. In the tree, `examples/tlpi` 
(`demo_inotify`) reads an inotify descriptor with a blocking `read()`; it 
installs no signal handler, so it does not change.
   
   ## Testing
   
   New test program `testing/fs/inotifytest` (apache/nuttx-apps#N): an 
`IN_CREATE` event for a new file, `IN_NONBLOCK` with no event (`EAGAIN`), and a 
signal with a handler that ends a waiting `read()` (`EINTR`). If the signal 
does not end `read()`, the test makes a file so that `read()` ends, and the 
check fails.
   
   Run on Fedora in the NuttX CI image (gcc, `-Wno-cpp -Werror`), QEMU on the 
host. "master" is apache/nuttx 1af7ac541e4 with the apps test; "this PR" adds 
this commit.
   
   | Configuration | master: `signal` | this PR: `signal` | ostest |
   |---|---|---|---|
   | qemu-intel64:nsh (flat, x86_64, CMake, KVM) | FAIL: `read()` returns the 
event made after 2 s | PASS: `read()` -1, `EINTR` | - |
   | qemu-intel64:knsh_romfs (kernel, x86_64, CMake, KVM) | FAIL | PASS | exit 
status 0 |
   | qemu-armv8a:nsh_smp (flat, SMP 2 CPUs, arm64, Make, TCG) | FAIL | PASS | 
exit status 0 |
   | rv-virt:knsh64 (kernel, riscv64, Make + export/import, TCG) | FAIL | PASS 
| exit status 0 |
   | rv-virt:pnsh64 (protected, riscv64) | - | builds | - |
   | qemu-armv8a:knsh (kernel, arm64) | - | builds | - |
   
   `event` and `nonblock` pass on master and with this PR. The test 
configurations add `CONFIG_FS_NOTIFY`, `CONFIG_FS_TMPFS` and 
`CONFIG_TESTING_INOTIFYTEST`.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


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