Use a more portable method to determine if PID is alive or not.
This commit is contained in:
parent
92c906f105
commit
3d7a6e41c6
|
@ -33,11 +33,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <pthread.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <pthread.h>
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
static void* bdberl_tpool_main(void* tpool);
|
static void* bdberl_tpool_main(void* tpool);
|
||||||
static TPoolJob* next_job(TPool* tpool);
|
static TPoolJob* next_job(TPool* tpool);
|
||||||
|
@ -390,12 +388,9 @@ char *bdberl_tpool_thread_id_string(DB_ENV *dbenv, pid_t pid, db_threadid_t tid,
|
||||||
// alive, ignore the thread ID.
|
// alive, ignore the thread ID.
|
||||||
int bdberl_tpool_thread_is_alive(DB_ENV *dbenv, pid_t pid, db_threadid_t tid, u_int32_t flags)
|
int bdberl_tpool_thread_is_alive(DB_ENV *dbenv, pid_t pid, db_threadid_t tid, u_int32_t flags)
|
||||||
{
|
{
|
||||||
static char path[200];
|
|
||||||
static struct stat sb;
|
|
||||||
int alive = 0;
|
int alive = 0;
|
||||||
|
|
||||||
snprintf(path, 200, "/dev/%d/status", pid);
|
if (kill(pid, 0) != ESRCH)
|
||||||
if (stat(path, &sb))
|
|
||||||
{
|
{
|
||||||
if (flags & DB_MUTEX_PROCESS_ONLY)
|
if (flags & DB_MUTEX_PROCESS_ONLY)
|
||||||
alive = 1;
|
alive = 1;
|
||||||
|
|
Loading…
Reference in a new issue