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

exit code from mtee instead piped process even with /E #4

Open
s0nic9 opened this issue Feb 15, 2019 · 3 comments
Open

exit code from mtee instead piped process even with /E #4

s0nic9 opened this issue Feb 15, 2019 · 3 comments

Comments

@s0nic9
Copy link

s0nic9 commented Feb 15, 2019

Hi, sorry for my english,
it seems mtee keep return an errorlevel code itself , instead errorlevel code of the piped process.
I've a 259 error code with mtee, I have 0 errorlevel with process output with >log.txt
Any idea ?
Thanks in advance for your job.

@ztou
Copy link

ztou commented Oct 27, 2020

same issue here, sometimes it could return expected exit code, but most of time, it will exit with 259.

call test.bat

"test.bat log..."
3

call test.bat | mtee.exe /E 1.log

"test.bat log..."
259

@andry81
Copy link

andry81 commented Feb 23, 2021

I had hit the same issue. I beleave it is some kind of synchronization or race condition issue in the expressions like this:

a | b
  1. b can start before a
  2. a can exit before start b

I think the case 2 happens here because if try to add some pause or sleep command into the a like:

pathping localhost -n -q 1 -p 100 >nul 2>&1

, where 100 is milliseconds

The issue disappears. In mine case 30 milliseconds was enough.

But in some cases even 50 ms is not enough.

@andry81
Copy link

andry81 commented Aug 11, 2021

For those who suffers from the issue, there is a better implementation without need an explicit pipe from cmd.exe: https://github.com/andry81/contools/tree/HEAD/Utilities/src/callf/help.tpl

You can run instead of:

call test.bat | mtee /E 1.log

This:

callf.exe /ret-child-exit /tee-stdout 1.log /tee-stderr-dup 1 "" "cmd.exe /c call test.bat"

It is better because it can pipe stdout separately from stderr and you can even pipe between processes with Administrator privileges isolation using named pipes.

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

3 participants