]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Add "yes" argument for the --modify-fds option.
authorAlexandra Hájková <ahajkova@redhat.com>
Tue, 6 May 2025 10:50:44 +0000 (06:50 -0400)
committerMark Wielaard <mark@klomp.org>
Thu, 22 May 2025 14:13:56 +0000 (16:13 +0200)
commitebd7dd5ea9504e0d8490507fd2b894647477b085
treefefe056571c416abfd017daf0738734af7cd4beb
parentf51744ed2d1f07c814b72853ca946da3c94de0f1
Add "yes" argument for the --modify-fds option.

Use --modify-fds=yes to restrict the option from affecting
the 0/1/2 file descriptors as they're often used for
stdin/tdout/stderr redirection.

The new possibility is named "yes" because "yes" is used
as the default in general. The default behaviour of the --modify-fds
option is then such, that highest available file descriptor is returned
execept when the lowest stdin/stdout/stderr (0, 1, 2) are available.

For example, if we want to redirect stdout to stderr by closing stdout
(file descriptor 1) and then calling dup (), file descriptor 1 will be
returned and not the highest number available. This is because the
following is a common pattern to redirect stdout to stderr:

close (1);
/* stdout becomes stderr */
ret = dup (2);

Add none/tests/track_yes.vgtest and none/tests/track_high.vgtest
tests to test --modify-fds=yes/high behave as expected.

https://bugs.kde.org/show_bug.cgi?id=502359
15 files changed:
.gitignore
NEWS
coregrind/m_main.c
coregrind/m_options.c
coregrind/m_syswrap/priv_syswrap-generic.h
docs/xml/manual-core.xml
include/pub_tool_options.h
none/tests/Makefile.am
none/tests/cmdline1.stdout.exp
none/tests/cmdline2.stdout.exp
none/tests/track_high.stderr.exp [new file with mode: 0644]
none/tests/track_high.vgtest [new file with mode: 0644]
none/tests/track_std.c [new file with mode: 0644]
none/tests/track_yes.stderr.exp [new file with mode: 0644]
none/tests/track_yes.vgtest [new file with mode: 0644]