Message ID | 1476793526-5303-1-git-send-email-yamamoto@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Tue, Oct 18, 2016 at 09:25:24PM +0900, YAMAMOTO Takashi wrote: > 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> Thank you for the fix. Would you mind updating the comment as well? Perhaps you could add a sentence like "We check the format of the status file to avoid the NetBSD file with the same name but different contents." Acked-by: Ben Pfaff <blp@ovn.org>
On Wed, Oct 19, 2016 at 1:46 AM, Ben Pfaff <blp@ovn.org> wrote: > On Tue, Oct 18, 2016 at 09:25:24PM +0900, YAMAMOTO Takashi wrote: > > 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> > > Thank you for the fix. Would you mind updating the comment as well? > Perhaps you could add a sentence like "We check the format of the status > file to avoid the NetBSD file with the same name but different > contents." > > Acked-by: Ben Pfaff <blp@ovn.org> > thank you. amended the comment and pushed to master.
diff --git a/tests/ovs-macros.at b/tests/ovs-macros.at index f3b7c36..b64d8cd 100644 --- a/tests/ovs-macros.at +++ b/tests/ovs-macros.at @@ -107,10 +107,10 @@ 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 + 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 } ]
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> --- tests/ovs-macros.at | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)