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

Theodore Ts'o
2025-07-21T11:41:46Z

On Sun, Jul 20, 2025 at 10:42:34PM -0700, Darrick J. Wong wrote:
> Oh wait no it turns out that libfuse obliterates std{in,out,err} in
> fuse_daemonize() by opening /dev/null and using that exact trick. So
> the only reason why I was ever getting any FUSE2FS debug output
> throughout *any* of the fuse+iomap development sprints was that glibc
> lets you assign stdout/stderr directly.
>
> freopen also won't work (at least on glibc) because its freopen
> implementation uses the dup2 trick which will be undone by libfuse.
>
> GREAT! I only got to debug my program because OF A WEIRD GLIBC QUIRK!!

So either we need to find some way to inhibit fuse_daemonize() and
then have fuse2fs handling doing the daemonization. Or maybe we can
arrange to have some kind callback to set up stdout/stderr after
fuse_main() is called? fuse_daemonize() is called from fuse_main(),
right?

- Ted