Skip to content

Commit 8954b58

Browse files
committed
Fix darwin-launcher.go to replace its process with cardano-launcher (binary)
1 parent d8a96ec commit 8954b58

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

nix/darwin-launcher.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ import (
55
"os"
66
"os/exec"
77
"path/filepath"
8+
"syscall"
89
)
910

1011
func main() {
12+
fmt.Fprintf(os.Stderr, "darwin-launcher: PID = %d\n", os.Getpid())
13+
1114
ex, err := os.Executable()
1215
if err != nil {
1316
panic(err)
@@ -17,14 +20,23 @@ func main() {
1720

1821
os.Setenv("PATH", fmt.Sprintf("%s:%s", installDir, os.Getenv("PATH")))
1922

20-
launcherConfig := filepath.Join(installDir, "../Resources/launcher-config.yaml")
21-
helper := filepath.Join(installDir, "../Resources/helper")
22-
23+
launcherConfigPath := filepath.Join(installDir, "../Resources/launcher-config.yaml")
24+
helperPath := filepath.Join(installDir, "../Resources/helper")
2325

24-
if err = exec.Command(helper).Run(); err != nil {
26+
helperCmd := exec.Command(helperPath)
27+
helperCmd.Stdout = os.Stdout
28+
helperCmd.Stderr = os.Stderr
29+
if err := helperCmd.Run(); err != nil {
2530
panic(err)
2631
}
27-
if err = exec.Command("cardano-launcher", "--config", launcherConfig).Run(); err != nil {
28-
panic(err)
32+
33+
// Replace the current process (otherwise WDIO complains in end-to-end tests):
34+
img := filepath.Join(installDir, "cardano-launcher")
35+
argv := []string{"cardano-launcher", "--config", launcherConfigPath}
36+
env := os.Environ()
37+
if err := syscall.Exec(img, argv, env); err != nil {
38+
fmt.Println(err)
2939
}
40+
41+
fmt.Fprintf(os.Stderr, "this won’t happen\n")
3042
}

0 commit comments

Comments
 (0)