cvs commit: LFS/BOOK/chapter06 sysklogd.xml

Alexander E. Patrakov see at the.sig
Wed May 12 18:31:36 PDT 2004


Matthew Burgess wrote:
> On Wed, 12 May 2004 08:30:17 +0600
> "Alexander E. Patrakov" <see at the.sig> wrote:
> 
> 
>>alexander at linuxfromscratch.org wrote:
>>
>>>alexander    04/05/11 20:27:21
>>>
>>>  Modified:    BOOK     Tag: b6_0 general.ent
>>>               BOOK/chapter01 Tag: b6_0 changelog.xml
>>>               BOOK/chapter03 Tag: b6_0 patches.xml
>>>               BOOK/chapter06 Tag: b6_0 sysklogd.xml
>>>  Log:
>>>  Added Sysklogd signal handling patch to the book
>>
>>I also want to do it in b5_1, because the bug is also there. May I do
>>that?
> 
> 
> Yes, assuming the patch is well tested.  What's the upstream status of
> this patch, not that they're likely to release a new version any time
> soon though!

The patch is included in Debian (in fact, when I by mistake posted a 
duplicate of this patch to the list, I took it from Debian). So it may 
be well tested.

Although "Is it well tested?" is not the completely right question. It 
would be right for closed-source or big software only. The right 
question is "Do you understand how it works?". The answer is below.

In the original source, syslogd.c, around line 893, we see:

if (fork()) {
	/* Parent /*
	signal (SIGTERM, doexit);
	/* stuff */
}

Then, in line 1020, we have (in the child):

if (getpid() != ppid)
	kill (ppid, SIGTERM);

The bug is that line 1021 in the child may be executed earlier than the 
"signal" line in the parent. If this happens, syslogd would be 
terminated by this signal and return a nonzero status code, and this 
confuses bootscripts.

The fix (to move signal() before fork()) is correct, because this avoids 
the race and does not affect the child, since the sigterm handler is set 
again in line 989 in the child.

-- 
Alexander E. Patrakov
To get my address: echo '0!42!+/6 at 5-3.535.25' | tr [!-:] [a-z] | tr n .



More information about the lfs-book mailing list