Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c91637f

Browse files
committed
fix: Try to fix macOS test?
1 parent 10a86de commit c91637f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cli/agent.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ func workspaceAgent() *cobra.Command {
5454
logger := slog.Make(sloghuman.Sink(cmd.ErrOrStderr()), sloghuman.Sink(logWriter)).Leveled(slog.LevelDebug)
5555
client := codersdk.New(coderURL)
5656

57+
usr1 := make(chan os.Signal, 1)
5758
if pprofEnabled {
59+
close(usr1)
5860
srvClose := serveHandler(cmd.Context(), logger, nil, pprofAddress, "pprof")
5961
defer srvClose()
6062
} else {
6163
// If pprof wasn't enabled at startup, allow a
6264
// `kill -USR1 $agent_pid` to start it.
63-
usr1 := make(chan os.Signal, 1)
6465
signal.Notify(usr1, syscall.SIGUSR1)
6566
go func() {
67+
defer close(usr1)
68+
defer signal.Stop(usr1)
69+
6670
select {
6771
case <-usr1:
6872
signal.Stop(usr1)
@@ -160,6 +164,7 @@ func workspaceAgent() *cobra.Command {
160164
},
161165
})
162166
<-cmd.Context().Done()
167+
<-usr1 // Wait for server to close (if started).
163168
return closer.Close()
164169
},
165170
}

0 commit comments

Comments
 (0)