net[linux]: fix lsof output in linux when no pid outputed.

pull/91/head
Shirou WAKAYAMA 10 years ago
parent 93e226a5e3
commit 5ae4dcc8ba

@ -22,12 +22,11 @@ func CallLsof(invoke Invoker, pid int32, args ...string) ([]string, error) {
} }
out, err := invoke.Command(lsof, cmd...) out, err := invoke.Command(lsof, cmd...)
if err != nil { if err != nil {
// if no pid found, lsof returnes code 1 // if no pid found, lsof returnes code 1 but have output.
if err.Error() == "exit status 1" && len(out) == 0 { if err.Error() == "exit status 1" && len(out) == 0 {
return []string{}, nil
}
return []string{}, err return []string{}, err
} }
}
lines := strings.Split(string(out), "\n") lines := strings.Split(string(out), "\n")
var ret []string var ret []string

Loading…
Cancel
Save