[Groonga-commit] groonga/groonga at c78ea64 [master] groonga: add error check for PID file open failure

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Aug 6 21:16:04 JST 2015


Kouhei Sutou	2015-08-06 21:16:04 +0900 (Thu, 06 Aug 2015)

  New Revision: c78ea6462aaeca5cc77320b59da0a185ac425a24
  https://github.com/groonga/groonga/commit/c78ea6462aaeca5cc77320b59da0a185ac425a24

  Message:
    groonga: add error check for PID file open failure
    
    GitHub: fix #368
    
    Reported by Hiroyuki Sato. Thanks!!!

  Modified files:
    src/groonga.c

  Modified: src/groonga.c (+9 -0)
===================================================================
--- src/groonga.c    2015-08-06 17:49:29 +0900 (87ce9f2)
+++ src/groonga.c    2015-08-06 21:16:04 +0900 (dc7d805)
@@ -21,6 +21,7 @@
 #include <ctype.h>
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <errno.h>
 
 #ifdef WIN32
 # define GROONGA_MAIN
@@ -32,6 +33,7 @@
 #include <grn_proc.h>
 #include <grn_db.h>
 #include <grn_util.h>
+#include <grn_error.h>
 
 #ifdef HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -544,6 +546,13 @@ create_pid_file(void)
   }
 
   pid_file = fopen(pid_file_path, "w");
+  if (!pid_file) {
+    fprintf(stderr,
+            "Failed to open PID file: <%s>: <%s>\n",
+            pid_file_path, grn_strerror(errno));
+    return;
+  }
+
   {
 #ifdef WIN32
     DWORD pid;
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index