You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2019/02/04 11:00:58 UTC

[Bug 63140] pid file may get corrupted and prevent httpd from starting

https://bz.apache.org/bugzilla/show_bug.cgi?id=63140

Nicolas Carrier <ca...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carrier.nicolas0@gmail.com

--- Comment #1 from Nicolas Carrier <ca...@gmail.com> ---
Created attachment 36417
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36417&action=edit
Avoids pid file creation race condition by using a temporary file.

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

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org