Don't leave fds created with --log-file, --xml-file or --log-socket open
commitfbd7596f8342f0b0fbbe088d960da839a8bdb839
authorMark Wielaard <mark@klomp.org>
Sun, 16 Jun 2024 19:23:08 +0000 (16 21:23 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 17 Jun 2024 15:45:24 +0000 (17 17:45 +0200)
treee115cab406b7c6e3f0f1415a0bc44d777cd61eb3
parent022fc29d5ffb4e9cca0db6b197c48b0b02ac9005
Don't leave fds created with --log-file, --xml-file or --log-socket open

prepare_sink_fd and prepare_sink_socket will create a new file
descriptor for the output sink. finalize_sink_fd then copies the fd
to the safe range, so it doesn't conflict with any application fds.

If we created the original fd ourselves, it was a VgLogTo_File or
VgLogTo_Socket, not VgLogTo_Fd, finalize_sink_fd should close it.

Also close socket when connecting fails in VG_(connect_via_socket).

Add a testcase for --log-file and --xml-file which prints output to
/dev/stderr

https://bugs.kde.org/show_bug.cgi?id=202770
https://bugs.kde.org/show_bug.cgi?id=311655
https://bugs.kde.org/show_bug.cgi?id=488379

Co-authored-by: Alexandra Hájková <ahajkova@redhat.com
NEWS
coregrind/m_libcfile.c
coregrind/m_libcprint.c
none/tests/Makefile.am
none/tests/log-track-fds.stderr.exp [new file with mode: 0644]
none/tests/log-track-fds.vgtest [new file with mode: 0644]
none/tests/xml-track-fds.stderr.exp [new file with mode: 0644]
none/tests/xml-track-fds.vgtest [new file with mode: 0644]