[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8554 - in gnunet/src: arm include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8554 - in gnunet/src: arm include util |
Date: |
Thu, 11 Jun 2009 18:49:14 -0600 |
Author: grothoff
Date: 2009-06-11 18:49:14 -0600 (Thu, 11 Jun 2009)
New Revision: 8554
Modified:
gnunet/src/arm/gnunet-service-arm.c
gnunet/src/include/gnunet_os_lib.h
gnunet/src/util/os_priority.c
Log:
fixing pid issues
Modified: gnunet/src/arm/gnunet-service-arm.c
===================================================================
--- gnunet/src/arm/gnunet-service-arm.c 2009-06-12 00:36:59 UTC (rev 8553)
+++ gnunet/src/arm/gnunet-service-arm.c 2009-06-12 00:49:14 UTC (rev 8554)
@@ -529,6 +529,7 @@
const char *statstr;
int statcode;
struct stat sbuf;
+ int ret;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
@@ -556,15 +557,13 @@
enum GNUNET_OS_ProcessStatusType statusType;
unsigned long statusCode;
- if (GNUNET_OS_process_status(pos->pid, &statusType, &statusCode) !=
GNUNET_OK)
- {
- GNUNET_log_strerror(GNUNET_ERROR_TYPE_ERROR,
"GNUNET_OS_process_status");
+ if (GNUNET_SYSERR == (ret = GNUNET_OS_process_status(pos->pid,
&statusType, &statusCode)))
continue;
- }
-
- if (statusType == GNUNET_OS_PROCESS_STOPPED || statusType ==
GNUNET_OS_PROCESS_RUNNING)
+ if ( (ret == GNUNET_NO) ||
+ (statusType == GNUNET_OS_PROCESS_STOPPED) ||
+ (statusType == GNUNET_OS_PROCESS_RUNNING) )
continue;
- else if (statusType == GNUNET_OS_PROCESS_EXITED)
+ if (statusType == GNUNET_OS_PROCESS_EXITED)
{
statstr = _( /* process termination method */ "exit");
statcode = statusCode;
Modified: gnunet/src/include/gnunet_os_lib.h
===================================================================
--- gnunet/src/include/gnunet_os_lib.h 2009-06-12 00:36:59 UTC (rev 8553)
+++ gnunet/src/include/gnunet_os_lib.h 2009-06-12 00:49:14 UTC (rev 8554)
@@ -163,7 +163,7 @@
* @param proc process ID
* @param type status type
* @param code return code/signal number
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @return GNUNET_OK on success, GNUNET_NO if the process is still running,
GNUNET_SYSERR otherwise
*/
int GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType
*type,
unsigned long *code);
Modified: gnunet/src/util/os_priority.c
===================================================================
--- gnunet/src/util/os_priority.c 2009-06-12 00:36:59 UTC (rev 8553)
+++ gnunet/src/util/os_priority.c 2009-06-12 00:49:14 UTC (rev 8554)
@@ -262,7 +262,7 @@
* @param proc process ID
* @param type status type
* @param code return code/signal number
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
+ * @return GNUNET_OK on success, GNUNET_NO if the process is still running,
GNUNET_SYSERR otherwise
*/
int
GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
@@ -270,9 +270,22 @@
{
#ifndef MINGW
int status;
+ int ret;
- if (proc != waitpid (0, &status, WNOHANG))
- return GNUNET_SYSERR;
+ ret = waitpid (0, &status, WNOHANG);
+ if ( (0 == ret) ||
+ ( (-1 == ret) &&
+ (ECHILD == errno) ) )
+ {
+ *type = GNUNET_OS_PROCESS_RUNNING;
+ *code = 0;
+ return GNUNET_NO;
+ }
+ if (proc != ret)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+ return GNUNET_SYSERR;
+ }
if (WIFEXITED (status))
{
*type = GNUNET_OS_PROCESS_EXITED;
@@ -306,6 +319,7 @@
if (INVALID_HANDLE_VALUE == h)
{
SetErrnoFromWinError (GetLastError ());
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "OpenProcess");
return GNUNET_SYSERR;
}
@@ -314,13 +328,11 @@
{
*type = GNUNET_OS_PROCESS_RUNNING;
*code = 0;
+ CloseHandle (h);
+ return GNUNET_NO;
}
- else
- {
- *type = GNUNET_OS_PROCESS_EXITED;
- *code = c;
- }
-
+ *type = GNUNET_OS_PROCESS_EXITED;
+ *code = c;
CloseHandle (h);
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8554 - in gnunet/src: arm include util,
gnunet <=