Giter Club home page Giter Club logo

Comments (7)

adamralph avatar adamralph commented on June 29, 2024

Hi @drpeck, thanks for raising this.

It sounds like the executable you are running is not well behaved. When it fails, if there is additional diagnostic information about the failure, in addition to the exit code, I would expect that information to be written to stderr, not stdout. Is the source code of the executable under your control? If so, I would first consider changing it to write the diagnostic information to stderr.

from simple-exec.

drpeck avatar drpeck commented on June 29, 2024

It's not under my control unfortunately. TBH I didn't/don't really understand stderr stuff, but I have managed to add a 2> error.log to pipe the errors to a file and I can read it from there.

It would be nice if it were handled all within managed code, but I'm sure it's not straightforward.

Thanks for your hard work.

from simple-exec.

adamralph avatar adamralph commented on June 29, 2024

I see, so it seems that the executable is well behaved, but you are invoking SimpleExec in a context where you don't see stderr in the console.

I need to give this a little more thought. This problem may belong slightly outside the simple contexts that SimpleExec is designed for. I'll get back to you ASAP.

In the meantime, the workaround you are using sounds fine for now.

from simple-exec.

adamralph avatar adamralph commented on June 29, 2024

BTW, I'm not sure I understand your listed alternative:

We could create Command.TryReadAsync which doesn't through an exception but the return type would state the error code.

It doesn't seem to address the problem you are facing, and it's possible to capture the exit code and swallow the exception today:

string output;
int exitCode;

try
{
    output = Read("foo.exe");
}
catch (ExitCodeException ex) // in 7.x you have to catch NonZeroExitCodeException
{
    exitCode = ex.ExitCode;
}

from simple-exec.

drpeck avatar drpeck commented on June 29, 2024

from simple-exec.

adamralph avatar adamralph commented on June 29, 2024

Well, the exception still doesn't give you the contents of stderr (or stdout). It only gives you the exit code. To be able to see the contents of stderr you need your 2> error.log workaround (or a new feature in SimpleExec).

BTW —

TBH I didn't/don't really understand stderr stuff...

The Wikipedia page has a good explanation.

from simple-exec.

adamralph avatar adamralph commented on June 29, 2024

@drpeck this will covered by #351

Thanks again for raising this.

from simple-exec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.