Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell script STDOUT goes missing #395

Open
phil-hands opened this issue May 25, 2023 · 1 comment
Open

shell script STDOUT goes missing #395

phil-hands opened this issue May 25, 2023 · 1 comment

Comments

@phil-hands
Copy link

Here is a demonstration of running a shell script under kcov, which makes the output go missing:

nimble% cat ./kcov_test/date.sh
#!/bin/sh
[ "$1" ] && exec >&8
date

% ./kcov_test/date.sh
Thu 25 May 09:32:29 CEST 2023

% kcov ./kcov_test/output ./kcov_test/date.sh

% kcov ./kcov_test/output ./kcov_test/date.sh redir_to_8
./kcov_test/date.sh: line 2: 8: Bad file descriptor

% kcov ./kcov_test/output ./kcov_test/date.sh redir_to_8 8>&1
Thu 25 May 09:32:33 CEST 2023

% kcov ./kcov_test/output date
Thu 25 May 09:32:55 CEST 2023

% kcov --version
kcov 38

That was on a Debian GNU/Linux 13 (aka "bookworm" or testing) system, with the packaged version of kcov (ver: 38+dfsg-1).

As you can see, if one redirects STDOUT in the script to FD 8 (chosen at random) and then redirect that back to STDOUT outside kcov, things work as expected. I presume this is unexpected.

I've had a glance at the Debian specific patches, and I don't see how they would produce this effect, so I suspect that it exists upstream, which is why I'm reporting this here.

@SimonKagstrom
Copy link
Owner

Can you retry it with the latest from git? I tested your script with my build, and it doesn't seem to happen there (on OSX though).

v38 is a few years old, so although I don't know of any specific fix of this, there are many changes since then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants