Fix closing of standard text streams for non-glibc system
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 5 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | term-utils/ttymsg: fix missing header for ARRAY_SIZE macroterm-utils/ | +1 | 0 replies | |
| 2/4 | login-utils/islocal: fix missing header for err macrologin-utils/ | +1 | 0 replies | |
| 3/4 | lib/closestream: move implementation into its own compilation unitdisk-utils/ include/ lib/ +5 more | +45 | 0 replies | |
| 4/4 | lib/closestream: fix assignment to read-only standard streamslib/ | +5 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/4] Fix closing of standard text streams for non-glibc system
Hi,
since commit 52aa1a661 (include/closestream: avoid close more than once, 2019-06-13), util-linux fails to build on musl libc based systems. The culprit here is that it introduced assignments to stderr and stdout, while the C89 standard explicitly notes that treating stderr and stdout as valid lvalues is not a requirement for any conforming C implementation. musl libc implemented these streams as extern FILE *const, and as a result assigning to these variables causes compiler errors.
Attached is a fix for this. Instead of assigning NULL to the streams, util-linux now uses a static variable streams_closed. Unfortunately, this fix necessitated some shifting around as closestream was previously implemented as header, only, and implementing static variables inside of a header is not going to work due to them being static to the single compilation unit, only. Thus I converted the code to move the implementation into "lib/closestream.c".
Regards
Patrick
Patrick Steinhardt (4):
term-utils/ttymsg: fix missing header for ARRAY_SIZE macro login-utils/islocal: fix missing header for err macro lib/closestream: move implementation into its own compilation unit lib/closestream: fix assignment to read-only standard streams
disk-utils/Makemodule.am | 2 + include/closestream.h | 90 +++------------------- lib/Makemodule.am | 1 + include/closestream.h => lib/closestream.c | 27 ++++--- login-utils/Makemodule.am | 4 +- login-utils/islocal.c | 1 + misc-utils/Makemodule.am | 10 ++- sys-utils/Makemodule.am | 9 ++- term-utils/ttymsg.c | 1 + text-utils/Makemodule.am | 6 +- 10 files changed, 52 insertions(+), 99 deletions(-) copy include/closestream.h => lib/closestream.c (75%)
Signature · 1 line
2.22.1