[PATCH 0/4] Fix closing of standard text streams for non-glibc system

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
2.22.1




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux