[Buildroot] [PATCH v2 1/1] package/apache: atomic creation of pid file.

Thomas Petazzoni thomas.petazzoni at bootlin.com
Mon Apr 13 12:09:23 UTC 2020


On Mon, 23 Sep 2019 07:47:27 +0000
Nicolas Carrier <nicolas.carrier at orolia.com> wrote:

> The original pattern for creating the pid file was:
> open_create(pid_file)
> write(pid_file, pid)
> close(pid_file)
> 
> But if a power outage occurs between open_create and write, the file will
> be empty and httpd will refuse to start afterwards unless the corrupt pid
> file is removed.
> 
> This patch uses the pattern:
> open_create(temp_pid_file)
> write(temp_pid_file)
> close(temp_pid_file)
> rename(temp_pid_file, pid_file)
> which is guaranteed to be atomic, provided that temp_pid_file and pid_file
> are located in the same file system, which this patch does by creating
> a temporary file name with the pattern:
>     pid_file_name + random_suffix
> 
> This patch has been submitted upstream, but did receive no answer at all:
>   https://bz.apache.org/bugzilla/show_bug.cgi?id=63140
> 
> 
> Signed-off-by: Nicolas Carrier <nicolas.carrier at orolia.com>
> ---

Your patch has been merged in upstream Apache, in a slightly different
form, but is not yet part of a released version of Apache. So I've
applied your commit, but replaced your change by the one that was
ultimately applied in upstream Apache.

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


More information about the buildroot mailing list