[Groonga-commit] groonga/groonga at 839f9e7 [master] Add grn_getpid for portability

Back to archive index

Susumu Yata null+****@clear*****
Fri Aug 18 18:00:41 JST 2017


Susumu Yata	2017-08-18 18:00:41 +0900 (Fri, 18 Aug 2017)

  New Revision: 839f9e7bf0cb6de171d0cd2564c40152193aeac6
  https://github.com/groonga/groonga/commit/839f9e7bf0cb6de171d0cd2564c40152193aeac6

  Message:
    Add grn_getpid for portability

  Modified files:
    include/groonga/portability.h
    lib/com.c
    lib/grn.h
    lib/logger.c
    src/groonga.c
    src/groonga_benchmark.c

  Modified: include/groonga/portability.h (+6 -0)
===================================================================
--- include/groonga/portability.h    2017-08-18 17:45:57 +0900 (1c7ee6c4e)
+++ include/groonga/portability.h    2017-08-18 18:00:41 +0900 (a45ba2f57)
@@ -193,3 +193,9 @@
 #else /* WIN32 */
 # define grn_isatty(stream) isatty((stream))
 #endif /* WIN32 */
+
+#ifdef WIN32
+# define grn_getpid() _getpid()
+#else /* WIN32 */
+# define grn_getpid() getpid()
+#endif /* WIN32 */

  Modified: lib/com.c (+1 -1)
===================================================================
--- lib/com.c    2017-08-18 17:45:57 +0900 (b029ac477)
+++ lib/com.c    2017-08-18 18:00:41 +0900 (59ce80b44)
@@ -455,7 +455,7 @@ grn_com_event_del(grn_ctx *ctx, grn_com_event *ev, grn_sock fd)
     } else {
       GRN_LOG(ctx, GRN_LOG_ERROR,
               "%04x| fd(%" GRN_FMT_SOCKET ") not found in ev(%p)",
-              getpid(), fd, ev);
+              grn_getpid(), fd, ev);
       return GRN_INVALID_ARGUMENT;
     }
   }

  Modified: lib/grn.h (+0 -2)
===================================================================
--- lib/grn.h    2017-08-18 17:45:57 +0900 (39990aa29)
+++ lib/grn.h    2017-08-18 18:00:41 +0900 (2c3fc20b1)
@@ -109,8 +109,6 @@
 #  endif
 # endif
 
-# define getpid() _getpid()
-
 # ifndef __GNUC__
 typedef SSIZE_T ssize_t;
 typedef int pid_t;

  Modified: lib/logger.c (+2 -2)
===================================================================
--- lib/logger.c    2017-08-18 17:45:57 +0900 (de8f8530b)
+++ lib/logger.c    2017-08-18 18:00:41 +0900 (d86b0b925)
@@ -425,10 +425,10 @@ grn_logger_putv(grn_ctx *ctx,
     }
     if (current_logger.flags & GRN_LOG_LOCATION) {
       grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE,
-                   "%d %s:%d %s()", getpid(), file, line, func);
+                   "%d %s:%d %s()", grn_getpid(), file, line, func);
     } else if (current_logger.flags & GRN_LOG_PID) {
       grn_snprintf(lbuf, LBUFSIZE, LBUFSIZE,
-                   "%d", getpid());
+                   "%d", grn_getpid());
     } else {
       lbuf[0] = '\0';
     }

  Modified: src/groonga.c (+3 -3)
===================================================================
--- src/groonga.c    2017-08-18 17:45:57 +0900 (07125bd7b)
+++ src/groonga.c    2017-08-18 18:00:41 +0900 (21ad8633c)
@@ -831,7 +831,7 @@ create_pid_file(void)
     fprintf(pid_file, "%" GRN_FMT_DWORD "\n", pid);
 #else /* WIN32 */
     pid_t pid;
-    pid = getpid();
+    pid = grn_getpid();
     fprintf(pid_file, "%d\n", pid);
 #endif /* WIN32 */
   }
@@ -881,7 +881,7 @@ daemonize(void)
       create_pid_file();
     } else {
       pid_t pid;
-      pid = getpid();
+      pid = grn_getpid();
       fprintf(stderr, "%d\n", pid);
     }
     break;
@@ -2340,7 +2340,7 @@ do_mbreq(grn_ctx *ctx, grn_edge *edge)
     break;
   case MBCMD_STAT :
     {
-      pid_t pid = getpid();
+      pid_t pid = grn_getpid();
       GRN_MSG_MBRES({
         grn_bulk_write(ctx, re, "pid", 3);
         grn_text_itoa(ctx, re, pid);

  Modified: src/groonga_benchmark.c (+1 -1)
===================================================================
--- src/groonga_benchmark.c    2017-08-18 17:45:57 +0900 (3960e471f)
+++ src/groonga_benchmark.c    2017-08-18 18:00:41 +0900 (77543c206)
@@ -3004,7 +3004,7 @@ main(int argc, char **argv)
     FILE *pid_file;
     pid_file = fopen(pid_path, "w");
     if (pid_file) {
-      fprintf(pid_file, "%d", getpid());
+      fprintf(pid_file, "%d", grn_getpid());
       fclose(pid_file);
     } else {
       fprintf(stderr,
-------------- next part --------------
HTML����������������������������...
下載 



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