Re: [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp

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

 



On Sun, Jul 20, 2025 at 09:27:41AM +0100, Sam James wrote:
> This seems to have introduced https://github.com/tytso/e2fsprogs/issues/235.

Heh, section 7.23.1 paragraph 4 of the latest C2y draft says that
stdin/stdout/stderr “are expressions of type "pointer to FILE" that
point to the FILE objects associated, respectively, with the standard
error, input, and output streams.”

The use of "expression" should have been the warning sign that a symbol
that can be mostly used as a pointer is not simply a pointer.

Later in footnote 318, they say [stdin/stdout/stderr] “need not be
modifiable lvalues to which the value returned by the fopen function
could be assigned.”

"need not be" is the magic phrasing that means musl and glibc are both
following the spec.  IOWs, every C programmer should reduce the amount
of brainpower they spend on their program's core algorithm so that they
can all be really smart about this quirk.

So yeah, you're right.

But we could also do:

	fd = open(logfile, O_WRONLY | O_CREAT | O_APPEND, 0666);
	dup2(fd, STDOUT_FILENO);
	dup2(fd, STDERR_FILENO);

and skip all this standards-worrying.  I would have just done that, but
for fear that somewhere there might be a library that actually *does* do
freopen and this trick won't work.

Yaaay, it's 2025 and we all still suuuuuuuck.

--D




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux