Page MenuHomeFreeBSD

rc.subr(8): Set procname to command by default to match documentation
Needs ReviewPublic

Authored by 0mp on Aug 28 2019, 8:18 AM.

Details

Reviewers
jilles
Summary
rc.subr(8): Set procname to command by default to match documentation

The rc.subr(8) manual reads that variable procname defaults to the value of
command. However, procname is never set to any value in the run_rc_command.
This patch sets procname to the value of command if procname is unset or empty.
As a result it is going to be possible to use the procname variable in
*cmd functions (e.g., start_cmd).

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 26158
Build 24673: arc lint + arc unit

Event Timeline

0mp created this revision.Aug 28 2019, 8:18 AM
0mp added a reviewer: jilles.Aug 28 2019, 1:11 PM
crees added a comment.Aug 28 2019, 1:31 PM

Inline.

libexec/rc/rc.subr
951

I think this is way too subtle.

How about we do away with $_procname and just set:

: ${procname:=${command}}

and use $procname directly in rc.subr?

0mp added a comment.Aug 28 2019, 3:08 PM

Answer inline

libexec/rc/rc.subr
951

Good idea. But as I was preparing the patch, I realized that it is not so starightforward.

Look at the lines 953-960: when procname is set, we start supporting two more keywords: status and poll. It seems that nothing is broken by this, however.

0mp updated this revision to Diff 61399.Aug 28 2019, 3:10 PM

Get rid of _procname entirely. Just use procname in the whole run_rc_command.

ian added a comment.Aug 28 2019, 3:18 PM
In D21450#466883, @0mp wrote:

Get rid of _procname entirely. Just use procname in the whole run_rc_command.

Remember that _procname is global if it's not declared local in the function. Have you ensured that this setting of _procname isn't relied-on by whatever calls this function?

cem removed a subscriber: cem.Aug 28 2019, 3:38 PM
0mp added a comment.Aug 28 2019, 4:17 PM
In D21450#466887, @ian wrote:
In D21450#466883, @0mp wrote:

Get rid of _procname entirely. Just use procname in the whole run_rc_command.

Remember that _procname is global if it's not declared local in the function. Have you ensured that this setting of _procname isn't relied-on by whatever calls this function?

Yes, I confirm that _procname is not used anywhere in src/libexec/rc.

It used as a local variable (although it is never declared local) in some rc.subr functions but it is always assigned a value (so it never depends on the value that could be passed over by the caller).

0mp marked an inline comment as done.Aug 29 2019, 7:59 AM