EKPD daemon in /usr/local/etc/rc.d getting killed before login
Yar Tikhiy
yar at comp.chem.msu.su
Fri Feb 10 00:56:26 PST 2006
On Thu, Feb 09, 2006 at 05:30:49PM +0900, Jarrod wrote:
>
> Dear All,
>
> Please tell me if this post should have gone elsewhere.
>
> The story goes, in brief, like this:
>
> * I have an EPSON PM-730C inkjet printer. Possibly not available outside
> Japan.
>
> * I found and installed the port: /usr/ports/print/pips730 in order to
> manage the printer's settings (resolution, quality, paper-type, etc.)
>
> * This port has, among other things, a daemon called "ekpd" which sits
> between lpd and the physical port and is responsible for filtering the
> output appropriately.
>
> * The port installs a startup script "ekpd.sh", in /usr/local/etc/rc.d
> by default, which can be enabled with the flag "ekpd_enable="YES"" in
> /etc/rc.conf.
>
> The problem was that the daemon would start ok (trace statements proved
> this), but then terminate as soon as the login prompt came up.
>
> Trace statements in the script file and in the ekpd executable file
> itself, eventually led me to discover that the daemon was somehow being
> killed off (or dying) once the /etc/rc system had finished booting FreeBSD.
>
> Looking around at some of the system daemons I ended up taking a leaf
> out of lpd.c and changing the daemon's startup code from doing a regular
> "fork()" to doing a "daemon(0, 0)" call instead.
>
> At this stage it looks like the problem is solved.
>
> My question is: Is there some documentation or warning somewhere which
> would have aided me in resolving this problem?
Perhaps the ekpd daemon hits some configuration/communication problems
and chooses to terminate? Most daemons can log their activity, so you
may want to investigate if it is possible by means of a configuration
file or command-line arguments to tell ekpd to log its actions to a file
or to a syslog facility. In the latter case (syslog) you'll need to
make sure that the facility used really gets logged to a file -- see
syslog(8) and syslog.conf(5).
> I read all the material I could find on the rc.d system and but I didn't
> see anything that suggested just doing a regular fork() would get you in
> trouble. I assume the problem has something to do with why the
> "daemon()" function exists in the first place?
>
> Is there any possibility that there could be a check somewhere in the rc
> system or ports system to prevent programs that don't call "daemon()" to
> initialize from being installed in rc.d?
This is hardly possible. The only case I can think of is when a
program forks into background and then tries to do terminal IO --
it will receive a signal. The daemon() function closes standard
IO descriptors and thus prevents the program from doing any IO on
them later. If this is the case, ekpd will die if started manually
by running "/usr/local/etc/rc.d/ekpd start", too.
--
Yar
More information about the freebsd-rc
mailing list