From 9884d06b80cb9e0a2fd0815bad86f30ff8b4111f Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Wed, 6 Mar 2024 20:11:46 -0500 Subject: [PATCH] net/interfaces: fix test hang on Darwin This test could hang because the subprocess was blocked on writing to the stdout pipe if we find the address we're looking for early in the output. Updates #cleanup Signed-off-by: Andrew Dunham Change-Id: I68d82c22a5d782098187ae6d8577e43063b72573 --- net/interfaces/interfaces_darwin_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/interfaces/interfaces_darwin_test.go b/net/interfaces/interfaces_darwin_test.go index ec53a0833..6767ec614 100644 --- a/net/interfaces/interfaces_darwin_test.go +++ b/net/interfaces/interfaces_darwin_test.go @@ -5,6 +5,7 @@ import ( "errors" + "io" "net/netip" "os/exec" "testing" @@ -69,6 +70,7 @@ func likelyHomeRouterIPDarwinExec() (ret netip.Addr, netif string, ok bool) { return } defer cmd.Wait() + defer io.Copy(io.Discard, stdout) // clear the pipe to prevent hangs var f []mem.RO lineread.Reader(stdout, func(lineb []byte) error {