Skip to content

Commit

Permalink
fix linux get processes command
Browse files Browse the repository at this point in the history
Signed-off-by: refaelm <refaelm@armosec.io>
  • Loading branch information
refaelm92 committed Nov 14, 2023
1 parent c688c98 commit 7116468
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pulsar/test/kill_port_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func getProcessesForPort(targetPort int) ([]int, error) {
case windows:
cmd = exec.Command("cmd", "/c", "netstat", "-ano", "|", "findstr", fmt.Sprintf(":%d", targetPort))
default:
cmd = exec.Command("sh", "-c", fmt.Sprintf("lsof -i tcp:%d | awk 'NR!=1 {print $2}'", targetPort))
cmd = exec.Command("sh", "-c", fmt.Sprintf("lsof -iTCP:%d -n -P | awk '/.*LISTEN.*/ { print $2 }'", targetPort))
}
output, err := cmd.Output()
if err != nil {
Expand Down

0 comments on commit 7116468

Please sign in to comment.