diff options
author | YAMAMOTO Takashi <yamamoto@ovn.org> | 2016-10-13 16:42:27 +0900 |
---|---|---|
committer | YAMAMOTO Takashi <yamamoto@ovn.org> | 2016-10-19 12:45:38 +0900 |
commit | 4fd3d0ec12e0e641f10d5443dded3165bf081524 (patch) | |
tree | ae68a755e962a36c8bba62c9037c0bc68f0b3c25 /tests | |
parent | 26ea2d4095e7ab7959703fa9b7f441367f875763 (diff) | |
download | openvswitch-4fd3d0ec12e0e641f10d5443dded3165bf081524.tar.gz |
Fix parent_pid on NetBSD
Fix recently introduced parent_pid macro on NetBSD 7.0.
On NetBSD, procfs status file looks like the following.
n7% cat /proc/$$/status
zsh 18509 12970 18509 18509 5,8 ctty,sldr 1476344459,639266 0,15575 0,15575 pause 1000 100,100,0
n7%
Signed-off-by: YAMAMOTO Takashi <yamamoto@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ovs-macros.at | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index f3b7c3651..123c71339 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -106,11 +106,12 @@ fi parent_pid () { # Using "ps" is portable to any POSIX system, but busybox "ps" (used in # e.g. Alpine Linux) is noncompliant, so we use a Linux-specific approach - # when it's available. - if test ! -e /proc/$1/status; then - ps -o ppid= -p $1 - else + # when it's available. We check the format of the status file to avoid + # the NetBSD file with the same name but different contents. + if egrep '^PPid:[[:space:]]*[0-9]*$' /proc/$1/status > /dev/null 2>&1; then sed -n 's/^PPid: \([0-9]*\)/\1/p' /proc/$1/status + else + ps -o ppid= -p $1 fi } ] |