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 66f2ddc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pulsar/test/kill_port_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func killPortProcess(targetPort int) error {
if err != nil {
return err
}
err = process.Signal(syscall.SIGTERM)
err = process.Signal(syscall.SIGKILL)

Check failure on line 36 in pulsar/test/kill_port_process.go

View workflow job for this annotation

GitHub Actions / test / Basic-Test

ineffectual assignment to err (ineffassign)
}
}
return nil
Expand All @@ -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 '/.*->.*:%d/ { print $2 }'", targetPort, targetPort))
}
output, err := cmd.Output()
if err != nil {
Expand Down

0 comments on commit 66f2ddc

Please sign in to comment.