Skip to content

Commit

Permalink
Bring sockstat(1) support back
Browse files Browse the repository at this point in the history
FreeBSD's fstat doesn't print listen addresses in the NAME column.

Refs #234
  • Loading branch information
dridi committed Dec 13, 2017
1 parent e6cce14 commit aaa91b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AC_PROG_MAKE_SET
AC_PROG_YACC
AC_PROG_LEX

AC_CHECK_PROGS(SOCKSTAT, [lsof fstat], [no])
AC_CHECK_PROGS(SOCKSTAT, [lsof sockstat fstat], [no])
if test "x$SOCKSTAT" = xno; then
AC_MSG_WARN([No tool found for socket inspection, tests will fail.])
fi
Expand Down
15 changes: 11 additions & 4 deletions src/tests/hitch_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ hitch_hosts() {
return
fi

if cmd sockstat && test "$(uname)" = FreeBSD
then
sockstat -P tcp -4 |
awk '$3 == '"$(hitch_pid)"' {
sub("\\*", "127.0.0.1", $6)
print $6
}'
return
fi

if cmd fstat
then
fstat -p "$(hitch_pid)" |
Expand All @@ -208,10 +218,7 @@ hitch_hosts() {
return
fi

# NB: we don't want to use sockstat(1) because the Linux port of the
# command forgot a crucial point: "port"ability.

fail "neither lsof nor fstat available"
fail "none of lsof, sockstat or fstat available"
}

#-
Expand Down

0 comments on commit aaa91b4

Please sign in to comment.