Checkresult file handling
Gerhard Lausser
Gerhard.Lausser at consol.de
Mon Jan 26 14:49:51 CET 2009
Hi,
i watched a 3.0.6 nagios instance with strace and saw the following:
[pid 24308] open("/usr/local/nagios/var/spool/checkresults/cBA2zEX",
O_RDWR|O_CREAT|O_EXCL, 0600) = 5
[pid 24308] rename("/usr/local/nagios/var/spool/checkresults/checkh8exMx",
"/usr/local/nagios/var/spool/checkresults/cBA2zEX") = 0
[pid 24308] close(5) = 0
[pid 24308] open("/usr/local/nagios/var/spool/checkresults/cBA2zEX.ok",
O_WRONLY|O_CREAT|O_TRUNC, 0600) = 5
[pid 24308] close(5) = 0
[pid 24308] unlink("/usr/local/nagios/var/spool/checkresults/checkh8exMx") =
-1 ENOENT (No such file or directory)
In the base/utils.c file is found:
/* move the original file */
result=my_rename(checkresult_file,output_file);
...
/* create an ok-to-go indicator file */
asprintf(&temp_buffer,"%s.ok",output_file);
if((output_file_fd=open(temp_buffer,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR
))>0)
close(output_file_fd);
my_free(temp_buffer);
...
/* delete the original file */
if(result==0)
unlink(checkresult_file);
}
If /* move the original file */ succeeded, then result is 0.
So in /* delete the original file */ a file is unlinked which no linker
exists under this name.
IMHO
if(result!=0) unlink....
would be the correct way.
Gerhard
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
More information about the Developers
mailing list