netutil: change mac lsof args. might be faster. didn't fix previous deadlock, though.

Change-Id: I159e9de4526683ae2f1fd2c18042b94e20029fdb
This commit is contained in:
Brad Fitzpatrick 2012-04-27 18:51:07 -07:00
parent 8bcae0d59b
commit 767c81071d
1 changed files with 9 additions and 1 deletions

View File

@ -121,7 +121,15 @@ func (p maybeBrackets) String() string {
func uidFromDarwinLsof(lip net.IP, lport int, rip net.IP, rport int) (uid int, err error) {
seek := fmt.Sprintf("%s:%d->%s:%d", maybeBrackets(lip), lport, maybeBrackets(rip), rport)
seekb := []byte(seek)
cmd := exec.Command("lsof", "-a", "-n", "-i", "-P")
cmd := exec.Command("lsof",
"-b", // avoid system calls that could block
"-w", // and don't warn about cases where -b fails
"-n", // don't resolve network names
"-P", // don't resolve network ports,
// TODO(bradfitz): pass down the uid we care about, then do: ?
//"-a", // AND the following together:
// "-u", strconv.Itoa(uid) // just this uid
"-itcp") // we only care about TCP connections
stdout, err := cmd.StdoutPipe()
if err != nil {
return