This matches how a non-timeout error is handled.
- rGe31fb97148f7: read builtin: Empty variables on timeout
read10.0 passed before, read11.0 failed before. Both pass.
This is more consistent, and probably more useful (while read loops tend not to treat EOF and read errors differently).
The whole error behaviour does not appear to match what most non-ash shells such as bash, ksh93, mksh and yash do (an immediate read error such as caused by <&- or 0>/dev/null leaves the variables unchanged), but POSIX seems to permit both (Consequences of errors in the read page "Default" pointing to XCU 1.4 Utility Description Defaults).
It is possible, but I'm not sure it is better.
Note that some ++ would have to be rearranged as well.
Existing tests use mktemp -d, placing the fifo into a temporary directory, to avoid the discouraged -u option.
Hmm, how portable is this? It is probably faster than forking off a child process to open the fifo for writing, which the standard requires and other tests do.
Some other tests do stuff like [ "$r" -gt 128 ] && [ "$(kill -l "$r")" = TERM ] to avoid depending on signal numbers.