net[linux]: fix lsof output

This commit is contained in:
Shirou WAKAYAMA 2015-10-11 22:15:47 +09:00
parent 5ae4dcc8ba
commit 6e3f81ce18
1 changed files with 2 additions and 2 deletions

View File

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