Skip to content

Commit 89dbb3c

Browse files
committed
Fix cleanup
1 parent 9f660d9 commit 89dbb3c

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

pkg/commands/compute/serve.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,6 @@ func (c *ServeCommand) startPushpin(spinner text.Spinner, out io.Writer) (pushpi
816816

817817
pushpinCtx := pushpinContext{}
818818

819-
var cleanup func()
820-
821819
// Generate a non-zero instance ID to represent this Pushpin instance and build temporary
822820
// files
823821
for {
@@ -908,12 +906,12 @@ func (c *ServeCommand) startPushpin(spinner text.Spinner, out io.Writer) (pushpi
908906
"--verbose",
909907
}
910908

911-
// Set up a context that can be canceled (prevent rogue Pushpin process)
909+
// Set up a context that can be canceled (prevent zombie Pushpin process)
912910
var pushpinCmd *exec.Cmd
913911
ctx, cancel := context.WithCancel(context.Background())
914912

915913
var once sync.Once
916-
cleanup = func() {
914+
pushpinCtx.cleanup = func() {
917915
once.Do(func() {
918916
if pushpinCmd != nil && pushpinCmd.Process != nil {
919917
if c.Globals.Verbose() {
@@ -942,7 +940,7 @@ func (c *ServeCommand) startPushpin(spinner text.Spinner, out io.Writer) (pushpi
942940
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT)
943941
go func() {
944942
<-sigCh
945-
cleanup()
943+
pushpinCtx.Close()
946944
}()
947945

948946
// gosec flagged this:

0 commit comments

Comments
 (0)