Skip to content

Commit 0e64e72

Browse files
committed
exec out of the stub
1 parent 0e41ed0 commit 0e64e72

7 files changed

+3
-25
lines changed

stubs/stub--darwin--arm64

-156 KB
Binary file not shown.

stubs/stub--darwin--x64

-159 KB
Binary file not shown.

stubs/stub--linux--arm

-113 KB
Binary file not shown.

stubs/stub--linux--arm64

-182 KB
Binary file not shown.

stubs/stub--linux--x64

-168 KB
Binary file not shown.

stubs/stub--win32--x64

-195 KB
Binary file not shown.

stubs/stub.go

+3-25
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ import (
1111
"io"
1212
"log"
1313
"os"
14-
"os/exec"
15-
"os/signal"
1614
"path"
1715
"path/filepath"
1816
"regexp"
1917
"strconv"
2018
"strings"
19+
"syscall"
2120
"time"
2221
)
2322

@@ -123,29 +122,8 @@ func main() {
123122
expandedCommand[key] = applicationDirectoryPlaceholderRegexp.ReplaceAllLiteralString(commandPart, applicationDirectory)
124123
}
125124

126-
command := exec.Command(expandedCommand[0], append(expandedCommand[1:], os.Args[1:]...)...)
127-
command.Stdin = os.Stdin
128-
command.Stdout = os.Stdout
129-
command.Stderr = os.Stderr
130-
131-
// Pass signals through to the child process.
132-
sigChan := make(chan os.Signal, 1)
133-
signal.Notify(sigChan)
134-
go func() {
135-
for sig := range sigChan {
136-
if command.Process != nil {
137-
command.Process.Signal(sig)
138-
}
139-
}
140-
}()
141-
142-
err = command.Run()
143-
var exitError *exec.ExitError
144-
if errors.As(err, &exitError) {
145-
os.Exit(exitError.ExitCode())
146-
} else if err != nil {
147-
log.Fatalf("caxa stub: Failed to run command: %v", err)
148-
}
125+
syscall.Exec(expandedCommand[0], append(expandedCommand, os.Args[1:]...), os.Environ())
126+
log.Fatalf("caxa stub: Failed to exec %s", expandedCommand[0])
149127
}
150128

151129
// Adapted from https://github.com/golang/build/blob/db2c93053bcd6b944723c262828c90af91b0477a/internal/untar/untar.go and https://github.com/mholt/archiver/tree/v3.5.0

0 commit comments

Comments
 (0)