You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/06/28 02:20:03 UTC
[lucy-commits] svn commit: r1140387 - /incubator/lucy/trunk/core/Lucy/Util/ProcessID.c
Author: marvin
Date: Tue Jun 28 00:20:02 2011
New Revision: 1140387
URL: http://svn.apache.org/viewvc?rev=1140387&view=rev
Log:
LUCY-166 Prefer POSIX over Windows.h for process ID.
Use the POSIX interface for getting a PID when it is available, instead of the
windows.h interface. This allows exec() to work properly under Cygwin and
fixes a failing test (t/109-shared_lock.t).
Modified:
incubator/lucy/trunk/core/Lucy/Util/ProcessID.c
Modified: incubator/lucy/trunk/core/Lucy/Util/ProcessID.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Util/ProcessID.c?rev=1140387&r1=1140386&r2=1140387&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Util/ProcessID.c (original)
+++ incubator/lucy/trunk/core/Lucy/Util/ProcessID.c Tue Jun 28 00:20:02 2011
@@ -16,8 +16,34 @@
#include "Lucy/Util/ProcessID.h"
+/********************************* UNIXEN *********************************/
+#if (defined(CHY_HAS_UNISTD_H) && defined(CHY_HAS_SIGNAL_H))
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+
+int
+lucy_PID_getpid(void) {
+ return getpid();
+}
+
+chy_bool_t
+lucy_PID_active(int pid) {
+ if (kill(pid, 0) == 0) {
+ return true; // signal succeeded, therefore pid active
+ }
+
+ if (errno != ESRCH) {
+ return true; // an error other than "pid not found", thus active
+ }
+
+ return false;
+}
+
/********************************* WINDOWS ********************************/
-#if (defined(CHY_HAS_WINDOWS_H) && defined(CHY_HAS_PROCESS_H))
+#elif (defined(CHY_HAS_WINDOWS_H) && defined(CHY_HAS_PROCESS_H))
#include <Windows.h>
#include <process.h>
@@ -47,32 +73,6 @@ lucy_PID_active(int pid) {
return false;
}
-/********************************* UNIXEN *********************************/
-#elif (defined(CHY_HAS_UNISTD_H) && defined(CHY_HAS_SIGNAL_H))
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-
-int
-lucy_PID_getpid(void) {
- return getpid();
-}
-
-chy_bool_t
-lucy_PID_active(int pid) {
- if (kill(pid, 0) == 0) {
- return true; // signal succeeded, therefore pid active
- }
-
- if (errno != ESRCH) {
- return true; // an error other than "pid not found", thus active
- }
-
- return false;
-}
-
#else
#error "Can't find a known process ID API."
#endif // OS switch.