LCDproc development and user support list

Text archives Help


[Lcdproc] Signalling in server/main.c


Chronological Thread 
  • From: bsdfan at nurfuerspam.de (bsdfan at nurfuerspam.de)
  • Subject: [Lcdproc] Signalling in server/main.c
  • Date: Sat, 31 Jan 2009 15:11:47 +0100

Hi,

after the problem of another user with the server startup I had a look at how
this works in the server and found the following comment:

/* BUG? According to the man page wait() should also return
* when a signal comes in that is caught. Instead it
* continues to wait. */

After reading the man page and experimenting a little bit I discovered this
to be reasonable, because SA_RESTART is set for the signal. This causes the
wait() call to be restarted.

Using the attached patch demonstrates the intended behaviour:

<LCDd.log>
Jan 31 14:34:23 <user.info> kirika LCDd: Set report level to 5, output to
syslog
Jan 31 14:34:23 <user.info> kirika LCDd: Server forking to background
Jan 31 14:34:23 <user.debug> kirika LCDd: daemonize()
Jan 31 14:34:23 <user.info> kirika LCDd: parent = 1185
Jan 31 14:34:23 <user.info> kirika LCDd: child = 1186
Jan 31 14:34:23 <user.debug> kirika LCDd:
install_signal_handlers(allow_reload=1)
Jan 31 ...
Jan 31 14:34:25 <user.debug> kirika LCDd: wave_to_parent(parent_pid=1185)
Jan 31 14:34:25 <user.info> kirika LCDd: child_ok_func(signal=30)
Jan 31 14:34:25 <user.debug> kirika LCDd: wait() failed: Interrupted system
call
Jan 31 14:34:25 <user.info> kirika LCDd: Got OK signal from child.
Jan 31 14:34:25 <user.debug> kirika LCDd: drop_privs(user="nobody")
Jan 31 14:34:25 <user.debug> kirika LCDd: do_mainloop()
</LCDd.log>

The likely reason this was introduced was to exit the server with the exit
code of the child, if something went wrong in its initialization phase.

The part that was supposed to run if the child completes initialization
successful was never run, because the server calls _exist() upon receipt of
the signal immediately.

The whole thing is only necessary because fork() happens before the drivers
are initialized. It was after the initialization before 0.5.0.

Does anybody of the former developers remember why fork() was moved before
the initialization?

Regards
Markus




Archive powered by MHonArc 2.6.18.

Top of page