Skip to content

Commit 07d82d0

Browse files
authored
refactor(lsof): clean-up and simplify lsof usage (#1426)
1 parent 3667df3 commit 07d82d0

File tree

5 files changed

+4
-3940
lines changed

5 files changed

+4
-3940
lines changed

cmd/flags_run_local_instance.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"debug/elf"
55
"fmt"
66
"net"
7+
"os/exec"
78
"strconv"
9+
"strings"
810
"time"
911

1012
"github.com/nanovms/ops/log"
@@ -142,10 +144,8 @@ func (flags *RunLocalInstanceCommandFlags) MergeToConfig(c *types.Config) error
142144
conn.Close()
143145

144146
message := fmt.Sprintf("Port %v is being used by other application", port)
145-
pid, err := checkPortUserPID(port)
146-
if err != nil {
147-
return err
148-
}
147+
lsofOut, _ := exec.Command("lsof", "-t", "-i", ":"+port).CombinedOutput()
148+
pid := strings.TrimSpace(string(lsofOut))
149149
if pid != "" {
150150
message += fmt.Sprintf(" (PID %s)", pid)
151151
}

cmd/flags_run_local_instance_unix.go

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)