NetBSD Problem Report #53145

From www@NetBSD.org  Sun Apr  1 04:35:56 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E79177A151
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  1 Apr 2018 04:35:56 +0000 (UTC)
Message-Id: <20180401043555.CACE17A1F3@mollari.NetBSD.org>
Date: Sun,  1 Apr 2018 04:35:55 +0000 (UTC)
From: bruce.lilly@gmail.com
Reply-To: bruce.lilly@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
X-Send-Pr-Version: www-1.0

>Number:         53145
>Category:       misc
>Synopsis:       Improved POSIX and X/OPEN conformance (/etc/rc.subr)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kre
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 01 04:40:00 +0000 2018
>Closed-Date:    Wed Apr 04 16:48:25 +0000 2018
>Last-Modified:  Wed Apr 04 16:48:25 +0000 2018
>Originator:     Bruce Lilly
>Release:        6.1.5-7.1.2
>Organization:
none
>Environment:
N/A
>Description:
/etc/rc.subr uses non-standard (vs. POSIX, X/OPEN) arguments to ps.

>How-To-Repeat:
Install heirloom-ps e.g. using pkgin.
su to root
Put one of the binary subdirectories (e.g. /usr/pkg/heirloom/bin/posix)
early in PATH
Run an rc command, e.g. '/etc/rc.d/cron status'
>Fix:
Patch /etc/rc.subr:
############# cut here #######################
*** etc/rc.subr Sat Nov  7 19:45:22 2015
--- /etc/rc.subr        Sat Mar 31 23:35:34 2018
***************
*** 213,215 ****
        fi
!       _find_processes $_procname ${_interpreter:-.} '-ax'
  }
--- 213,215 ----
        fi
!       _find_processes $_procname ${_interpreter:-.} '-A'
  }
***************
*** 272,274 ****
        _proccheck='
!               ps -o "pid,command" '"$_psargs"' |
                while read _npid '"$_fp_args"'; do
--- 272,274 ----
        _proccheck='
!               ps -o "pid,comm" '"$_psargs"' |
                while read _npid '"$_fp_args"'; do
############# cut here #######################

Tested on NetBSD 6.1.5, 7.0, 7.0.2, 7.1, 7.1.2 with NetBSD /bin/ps and with all variants (posix/,posix2001/,s42/, and plain) of heirloom-ps.

Change of '-ax' to '-A' is reported on the NetBSD /bin/ps man page as equivalent and conforms to POSIX and X/OPEN standards.  Change of '-o pid,command' to '-o pid,comm' is supported by NetBSD /bin/ps (although it is undocumented) and conforms to POSIX and X/OPEN standards.

Bonus: /etc/rc.subr file size is reduced by 4 bytes.

>Release-Note:

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
Date: Sun, 01 Apr 2018 14:16:43 +0700

     Date:        Sun,  1 Apr 2018 04:40:01 +0000 (UTC)
     From:        bruce.lilly@gmail.com
     Message-ID:  <20180401044001.0628C7A212@mollari.NetBSD.org>

   | Change of '-ax' to '-A' is reported on the NetBSD /bin/ps man page as equivalent

 Yes, -ax and -A are the same and that can be changed.

   | Change of '-o pid,command' to '-o pid,comm' is supported by NetBSD /bin/ps
   | (although it is undocumented) and conforms to POSIX and X/OPEN standards.

 It is documented (at least as far back as NetBSD 6) but does not mean the
 same thing, NetBSD's "comm" is the same as the POSIX "comm", whereas
 NetBSD's "command" is the same as POSIX "args" (which is also supported
 on NetBSD as an alias for "command") so if  you can verify that changing it
 from "pid,command" to "pid,args" works for you (with the heirloom version of
 ps in use) I cannot see any reason we should not make that change.

 I doubt that a pullup to -6 or -7 is warranted though (and perhaps not even -8)

 kre

Responsible-Changed-From-To: misc-bug-people->kre
Responsible-Changed-By: kre@NetBSD.org
Responsible-Changed-When: Sun, 01 Apr 2018 07:24:45 +0000
Responsible-Changed-Why:
I am looking into this PR


From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
Date: Sun, 01 Apr 2018 14:20:47 +0700

 And now that I read th man page more closely, I see that "args" is also
 documented (as an alias for "command") so there's no issue about
 using undocumented features.

 kre

 ps: if you just saw this message on source-changes-d that was a mistake,
 this is where it was meant to go!

From: Bruce Lilly <bruce.lilly@gmail.com>
To: gnats-bugs@netbsd.org
Cc: misc-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
Date: Sun, 1 Apr 2018 07:32:36 -0400

 On Sun, Apr 1, 2018 at 3:20 AM, Robert Elz <kre@munnari.oz.au> wrote:
 > The following reply was made to PR misc/53145; it has been noted by GNATS.
 >
 > From: Robert Elz <kre@munnari.OZ.AU>
 > To: gnats-bugs@NetBSD.org
 > Cc:
 > Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
 > Date: Sun, 01 Apr 2018 14:16:43 +0700
 >
 >      Date:        Sun,  1 Apr 2018 04:40:01 +0000 (UTC)
 >      From:        bruce.lilly@gmail.com
 >      Message-ID:  <20180401044001.0628C7A212@mollari.NetBSD.org>
 >
 >    | Change of '-ax' to '-A' is reported on the NetBSD /bin/ps man page as equivalent
 >
 >  Yes, -ax and -A are the same and that can be changed.
 >
 >    | Change of '-o pid,command' to '-o pid,comm' is supported by NetBSD /bin/ps
 >    | (although it is undocumented) and conforms to POSIX and X/OPEN standards.
 >
 >  It is documented (at least as far back as NetBSD 6) but does not mean the
 >  same thing, NetBSD's "comm" is the same as the POSIX "comm", whereas
 >  NetBSD's "command" is the same as POSIX "args" (which is also supported
 >  on NetBSD as an alias for "command") so if  you can verify that changing it
 >  from "pid,command" to "pid,args" works for you (with the heirloom version of
 >  ps in use) I cannot see any reason we should not make that change.

 It works for me (output same except for whitespace, which won't affect
 operation):

 root@e2500sa:/root# /bin/ps -p 1 -o pid,args
 PID COMMAND
   1 init
 root@e2500sa:/root# /usr/pkg/heirloom/bin/ps -p 1 -o pid,args
   PID COMMAND
     1 init
 root@e2500sa:/root# /usr/pkg/heirloom/bin/posix/ps -p 1 -o pid,args
   PID COMMAND
     1 init
 root@e2500sa:/root# /usr/pkg/heirloom/bin/posix2001/ps -p 1 -o pid,args
   PID COMMAND
     1 init
 root@e2500sa:/root# /usr/pkg/heirloom/bin/s42/ps -p 1 -o pid,args
   PID COMMAND
     1 init

 >  I doubt that a pullup to -6 or -7 is warranted though (and perhaps not even -8)
 >
 >  kre

 FYI, I looked briefly at the version (1.100) of rc.subr in -current
 (a.k.a. -8), and
 I believe the patch should work for that version also [ultimately, the
 script calls
 ps via _find_processes either with -p <pid> or -A (-ax) in addition to
 the output
 (-o ...) args].

From: Bruce Lilly <bruce.lilly@gmail.com>
To: gnats-bugs@netbsd.org
Cc: kre@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
Date: Sun, 1 Apr 2018 08:30:04 -0400

 P.S.  As far as I can tell, this is/was the only remaining use of non-POSIX
 ps args in scripts in the distribution.

 On Sun, Apr 1, 2018 at 7:35 AM, Bruce Lilly <bruce.lilly@gmail.com> wrote:
 > The following reply was made to PR misc/53145; it has been noted by GNATS.
 >
 > From: Bruce Lilly <bruce.lilly@gmail.com>
 > To: gnats-bugs@netbsd.org
 > Cc: misc-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
 > Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
 > Date: Sun, 1 Apr 2018 07:32:36 -0400
 >
 >  On Sun, Apr 1, 2018 at 3:20 AM, Robert Elz <kre@munnari.oz.au> wrote:
 >  > The following reply was made to PR misc/53145; it has been noted by GNATS.
 >  >
 >  > From: Robert Elz <kre@munnari.OZ.AU>
 >  > To: gnats-bugs@NetBSD.org
 >  > Cc:
 >  > Subject: Re: misc/53145: Improved POSIX and X/OPEN conformance (/etc/rc.subr)
 >  > Date: Sun, 01 Apr 2018 14:16:43 +0700
 >  >
 >  >      Date:        Sun,  1 Apr 2018 04:40:01 +0000 (UTC)
 >  >      From:        bruce.lilly@gmail.com
 >  >      Message-ID:  <20180401044001.0628C7A212@mollari.NetBSD.org>
 >  >
 >  >    | Change of '-ax' to '-A' is reported on the NetBSD /bin/ps man page as equivalent
 >  >
 >  >  Yes, -ax and -A are the same and that can be changed.
 >  >
 >  >    | Change of '-o pid,command' to '-o pid,comm' is supported by NetBSD /bin/ps
 >  >    | (although it is undocumented) and conforms to POSIX and X/OPEN standards.
 >  >
 >  >  It is documented (at least as far back as NetBSD 6) but does not mean the
 >  >  same thing, NetBSD's "comm" is the same as the POSIX "comm", whereas
 >  >  NetBSD's "command" is the same as POSIX "args" (which is also supported
 >  >  on NetBSD as an alias for "command") so if  you can verify that changing it
 >  >  from "pid,command" to "pid,args" works for you (with the heirloom version of
 >  >  ps in use) I cannot see any reason we should not make that change.
 >
 >  It works for me (output same except for whitespace, which won't affect
 >  operation):
 >
 >  root@e2500sa:/root# /bin/ps -p 1 -o pid,args
 >  PID COMMAND
 >    1 init
 >  root@e2500sa:/root# /usr/pkg/heirloom/bin/ps -p 1 -o pid,args
 >    PID COMMAND
 >      1 init
 >  root@e2500sa:/root# /usr/pkg/heirloom/bin/posix/ps -p 1 -o pid,args
 >    PID COMMAND
 >      1 init
 >  root@e2500sa:/root# /usr/pkg/heirloom/bin/posix2001/ps -p 1 -o pid,args
 >    PID COMMAND
 >      1 init
 >  root@e2500sa:/root# /usr/pkg/heirloom/bin/s42/ps -p 1 -o pid,args
 >    PID COMMAND
 >      1 init
 >
 >  >  I doubt that a pullup to -6 or -7 is warranted though (and perhaps not even -8)
 >  >
 >  >  kre
 >
 >  FYI, I looked briefly at the version (1.100) of rc.subr in -current
 >  (a.k.a. -8), and
 >  I believe the patch should work for that version also [ultimately, the
 >  script calls
 >  ps via _find_processes either with -p <pid> or -A (-ax) in addition to
 >  the output
 >  (-o ...) args].
 >

From: "Robert Elz" <kre@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53145 CVS commit: src/etc
Date: Sun, 1 Apr 2018 18:26:51 +0000

 Module Name:	src
 Committed By:	kre
 Date:		Sun Apr  1 18:26:51 UTC 2018

 Modified Files:
 	src/etc: rc.subr

 Log Message:
 PR misc/53145 (Bruce Lilly)

 Use ps -A instead of ps -ax (-A means -ax, but -A is posix, -x is not)
 Use ps -o args instead of ps -o command (same reason).

 This makes no difference when the ps used is /bin/ps on NetBSD, but
 can make a difference when some other ps command gets invoked instead.

 XXX pullup -8


 To generate a diff of this commit:
 cvs rdiff -u -r1.100 -r1.101 src/etc/rc.subr

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->pending-pullups
State-Changed-By: kre@NetBSD.org
State-Changed-When: Wed, 04 Apr 2018 04:03:37 +0000
State-Changed-Why:
pullup-8 #689


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/53145 CVS commit: [netbsd-8] src/etc
Date: Wed, 4 Apr 2018 16:07:33 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Wed Apr  4 16:07:33 UTC 2018

 Modified Files:
 	src/etc [netbsd-8]: rc.subr

 Log Message:
 Pull up following revision(s) (requested by kre in ticket #689):
 	etc/rc.subr: revision 1.101

 PR misc/53145 (Bruce Lilly)

 Use ps -A instead of ps -ax (-A means -ax, but -A is posix, -x is not)
 Use ps -o args instead of ps -o command (same reason).

 This makes no difference when the ps used is /bin/ps on NetBSD, but
 can make a difference when some other ps command gets invoked instead.

 XXX pullup -8


 To generate a diff of this commit:
 cvs rdiff -u -r1.100 -r1.100.4.1 src/etc/rc.subr

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: kre@NetBSD.org
State-Changed-When: Wed, 04 Apr 2018 16:48:25 +0000
State-Changed-Why:
Pullups completed


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.