Skip to content

Commit 0243a5b

Browse files
ZauberNerddeadprogram
authored andcommitted
src/os: add stubs for exec.ExitError and ProcessState.ExitCode
This commit adds stubs for the `ExitError` struct of the `exec` package and `ProcessState.ExitCode()` of the `os` package. Since the `os/exec` is listed as unsupported, stubbing these methods and structs should be enough to get programs that use these to compile.
1 parent 1fac41d commit 0243a5b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/os/exec.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ func (p *ProcessState) Success() bool {
3434
return false // TODO
3535
}
3636

37+
// ExitCode returns the exit code of the exited process, or -1
38+
// if the process hasn't exited or was terminated by a signal.
39+
func (p *ProcessState) ExitCode() int {
40+
return -1 // TODO
41+
}
42+
3743
type Process struct {
3844
Pid int
3945
}

src/os/exec/exec.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package exec
2+
3+
import "os"
4+
5+
// An ExitError reports an unsuccessful exit by a command.
6+
type ExitError struct {
7+
*os.ProcessState
8+
9+
// Stderr holds a subset of the standard error output from the
10+
// Cmd.Output method if standard error was not otherwise being
11+
// collected.
12+
//
13+
// If the error output is long, Stderr may contain only a prefix
14+
// and suffix of the output, with the middle replaced with
15+
// text about the number of omitted bytes.
16+
//
17+
// Stderr is provided for debugging, for inclusion in error messages.
18+
// Users with other needs should redirect Cmd.Stderr as needed.
19+
Stderr []byte
20+
}
21+
22+
func (e *ExitError) Error() string {
23+
return e.ProcessState.String()
24+
}

0 commit comments

Comments
 (0)