From 3503c19a96f3d5c689967e6d7db61cd0f8dd10f0 Mon Sep 17 00:00:00 2001 From: Mateus Miranda Date: Mon, 29 Nov 2021 12:32:37 +0100 Subject: [PATCH] Avoid leaving cloudflared orphan process (#6) --- cfdtunnel/cfdtunnel.go | 4 ++-- cfdtunnel/cfdtunnel_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cfdtunnel/cfdtunnel.go b/cfdtunnel/cfdtunnel.go index 143da4f..67f2920 100644 --- a/cfdtunnel/cfdtunnel.go +++ b/cfdtunnel/cfdtunnel.go @@ -91,7 +91,7 @@ func commandKill(cmd *exec.Cmd) { func (args Arguments) runSubCommand() { log.Debugf("Running subcommand: %v", args.Command) if !checkSubCommandExists(args.Command) { - os.Exit(1) + return } output, err := exec.Command(args.Command, args.Args...).CombinedOutput() @@ -99,7 +99,7 @@ func (args Arguments) runSubCommand() { fmt.Println(string(output)) if err != nil { - log.Fatalf("An error occurred trying to run the command %v: %v", args.Command, err) + log.Errorf("An error occurred trying to run the command %v: %v", args.Command, err) } } diff --git a/cfdtunnel/cfdtunnel_test.go b/cfdtunnel/cfdtunnel_test.go index c73ab3d..08ab171 100644 --- a/cfdtunnel/cfdtunnel_test.go +++ b/cfdtunnel/cfdtunnel_test.go @@ -192,8 +192,8 @@ func TestRunSubCommandMissing(t *testing.T) { // Cast the error as *exec.ExitError and compare the result e, ok := err.(*exec.ExitError) - assert.True(t, ok) - assert.Equal(t, "exit status 1", e.Error()) + assert.False(t, ok) + assert.Nil(t, e) }