NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: powerd script failure

I wrote:
>> I was using a simple script which I wrote long ago to let sleep my
>> machine by power button through powerd(9), but recently I decided to
>> use the standard /etc/powerd/scripts/sleep_button script.
>> So I copied sleep_button script file to power_button and pressed power
>> button, and found that it fails weird way.  The machine suspends, but
>> when resuming, default network route is not set.  After tracking the
>> behavior by sprinkling debug messages, I found /etc/rc.d/networks is
>> failing after this line:
>>              echo -n 'Configuring network interfaces:'
>> In fact, the script exits with exit code 141 upon any use of "echo -n"
>> in the script.  Simple "echo" doesn't have problem, but "echo -n"
>> fails.  And if I replace "echo -n" with "/bin/echo -n", script works
>> without problem.

I've finally decided to track the problem and found that /etc/rc.subr
defines echo(), which, if "-n" option is used, calls
_flush_rc_output() which calls print_rc_metadata(), which has:
        if [ -n "$_rc_postprocessor_fd" ]; then
                command printf "%s%s\n" "$rc_metadata_prefix" "$1" \

When booting the system, /etc/rc rc_real_work() exports envvar
_rc_postprocessor_fd.  powerd(8) inherits this envvar, and exports it
when spawning powerd scripts.  Later, when sleep button is pressed,
/etc/powerd/scripts/sleep_button calls /etc/rc.d/network, /etc/rc.subr
is included, and echo() calls _flush_rc_outpu() then
print_rc_metadata(), but postprocessor process doesn't exist anymore.

Not sure how to fix it.  Either rc(8) or powerd(8) should clear
environment variables.

                                                FUKUMOTO Atsushi

Home | Main Index | Thread Index | Old Index