Re: $pexp in re.subr(8)
Stuart Henderson writes: > This means that the regular expression must match the full process > string. Equivalent to providing an expression with ^ at the start and > $ at the end of the. I see, so the documentation is already correct, sorry, and thanks for the explanation.
Re: $pexp in re.subr(8)
On 2020/08/06 18:12, Thomas Levine wrote: > The present patch changes the rc.subr(8) manual page to match > the implementation. > > The current manual page for rc.subr(8) says that $pexp is "A regular > expression to be passed to pgrep(1) in order to find the desired process > or to be passed to pkill(1) to stop it." > > The file /etc/rc.d/rc.subr currently uses $pexp only as a fixed > expression, with the -xf flags. > > > grep pexp /etc/rc.d/rc.subr > pexp=${pexp} > multicast nfs_server pexp pf pkg_scripts shlib_dirs spamd_black > pgrep -T "${daemon_rtable}" -q -xf "${pexp}" > pkill -HUP -T "${daemon_rtable}" -xf "${pexp}" > pkill -T "${daemon_rtable}" -xf "${pexp}" > # make sure pexp matches the process (i.e. doesn't include the quotes) > pexp="$(eval echo ${daemon}${daemon_flags:+ ${daemon_flags}})" > > The -xf flags are explained in the pgrep(1) and pkill(1) man page. > > -x Require an exact match of the process name, or argument > list if -f is given. The default is to match any substring. This means that the regular expression must match the full process string. Equivalent to providing an expression with ^ at the start and $ at the end of the. > > The present patch replaces instances of "regular expression" with > "fixed expression". > > I also think a better phrasing would be to explain in the rc.subr(8) > man page that $pexp is a substring of the process name with flags and > that it uses pgrep with -xf. I might eventually do that in a separate > patch. > > > Index: rc.subr.8 > === > RCS file: /cvs/src/share/man/man8/rc.subr.8,v > retrieving revision 1.37 > diff -u -p -r1.37 rc.subr.8 > --- rc.subr.8 21 Feb 2020 00:47:21 - 1.37 > +++ rc.subr.8 7 Aug 2020 00:46:34 - > @@ -184,7 +184,7 @@ call > .It Ic rc_check > Search for processes of the service with > .Xr pgrep 1 > -using the regular expression given in the > +using the fixed expression given in the > .Va pexp > variable. > .It Ic rc_start > @@ -199,7 +199,7 @@ Send a > .Dv SIGTERM > signal using > .Xr pkill 1 > -on the regular expression given in the > +on the fixed expression given in the > .Va pexp > variable. > .It Ic rc_reload > @@ -207,7 +207,7 @@ Send a > .Dv SIGHUP > signal using > .Xr pkill 1 > -on the regular expression given in the > +on the fixed expression given in the > .Va pexp > variable. > One has to make sure that sending > @@ -267,7 +267,7 @@ functions. > User to run the daemon as, using > .Xr su 1 . > .It Va pexp > -A regular expression to be passed to > +A fixed expression to be passed to > .Xr pgrep 1 > in order to find the desired process or to be passed to > .Xr pkill 1 >
Re: $pexp in re.subr(8)
On Thu, August 6, 2020 9:12 pm, Thomas Levine wrote: > The present patch changes the rc.subr(8) manual page to match > the implementation. > > The current manual page for rc.subr(8) says that $pexp is "A regular > expression to be passed to pgrep(1) in order to find the desired process > or to be passed to pkill(1) to stop it." > > The file /etc/rc.d/rc.subr currently uses $pexp only as a fixed > expression, with the -xf flags. > > > grep pexp /etc/rc.d/rc.subr > pexp=${pexp} > multicast nfs_server pexp pf pkg_scripts shlib_dirs spamd_black > pgrep -T "${daemon_rtable}" -q -xf "${pexp}" > pkill -HUP -T "${daemon_rtable}" -xf "${pexp}" > pkill -T "${daemon_rtable}" -xf "${pexp}" > # make sure pexp matches the process (i.e. doesn't include the quotes) > pexp="$(eval echo ${daemon}${daemon_flags:+ ${daemon_flags}})" > > The -xf flags are explained in the pgrep(1) and pkill(1) man page. > > -x Require an exact match of the process name, or argument > list if -f is given. The default is to match any substring. > > The present patch replaces instances of "regular expression" with > "fixed expression". > I'm not sure what you mean by a "fixed expression". A string? But reread the pgrep/pkill manpage. They take a pattern as an operand which is described to be an extended regular expression. This is true. Even with -x. Try it.
$pexp in re.subr(8)
The present patch changes the rc.subr(8) manual page to match the implementation. The current manual page for rc.subr(8) says that $pexp is "A regular expression to be passed to pgrep(1) in order to find the desired process or to be passed to pkill(1) to stop it." The file /etc/rc.d/rc.subr currently uses $pexp only as a fixed expression, with the -xf flags. > grep pexp /etc/rc.d/rc.subr pexp=${pexp} multicast nfs_server pexp pf pkg_scripts shlib_dirs spamd_black pgrep -T "${daemon_rtable}" -q -xf "${pexp}" pkill -HUP -T "${daemon_rtable}" -xf "${pexp}" pkill -T "${daemon_rtable}" -xf "${pexp}" # make sure pexp matches the process (i.e. doesn't include the quotes) pexp="$(eval echo ${daemon}${daemon_flags:+ ${daemon_flags}})" The -xf flags are explained in the pgrep(1) and pkill(1) man page. -x Require an exact match of the process name, or argument list if -f is given. The default is to match any substring. The present patch replaces instances of "regular expression" with "fixed expression". I also think a better phrasing would be to explain in the rc.subr(8) man page that $pexp is a substring of the process name with flags and that it uses pgrep with -xf. I might eventually do that in a separate patch. Index: rc.subr.8 === RCS file: /cvs/src/share/man/man8/rc.subr.8,v retrieving revision 1.37 diff -u -p -r1.37 rc.subr.8 --- rc.subr.8 21 Feb 2020 00:47:21 - 1.37 +++ rc.subr.8 7 Aug 2020 00:46:34 - @@ -184,7 +184,7 @@ call .It Ic rc_check Search for processes of the service with .Xr pgrep 1 -using the regular expression given in the +using the fixed expression given in the .Va pexp variable. .It Ic rc_start @@ -199,7 +199,7 @@ Send a .Dv SIGTERM signal using .Xr pkill 1 -on the regular expression given in the +on the fixed expression given in the .Va pexp variable. .It Ic rc_reload @@ -207,7 +207,7 @@ Send a .Dv SIGHUP signal using .Xr pkill 1 -on the regular expression given in the +on the fixed expression given in the .Va pexp variable. One has to make sure that sending @@ -267,7 +267,7 @@ functions. User to run the daemon as, using .Xr su 1 . .It Va pexp -A regular expression to be passed to +A fixed expression to be passed to .Xr pgrep 1 in order to find the desired process or to be passed to .Xr pkill 1