Skip to content

os/exec: Cmd can only be executed once, but that isn't documented #10305

@AlexFinkel

Description

@AlexFinkel

Once an exec.Cmd has been Run (e.g. through .Run, .Output or .CombinedOutput) calling one of these run methods again will result in an error.

  1. This fact isn't documented.
  2. The resulting error messages don't clearly identify what caused the problem.
  3. This behaviour probably isn't necessary; for many commands it makes perfectly good sense to run them more than once.

I'm not talking about parallel execution here, this is running, checking the output, then running again.

Example error message from calling CombinedOutput more than once:
"exec: Stdout already set."
http://play.golang.org/p/Aaj3Gbva_S

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions