diff options
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/common-utils.c | 28 | ||||
-rw-r--r-- | libglusterfs/src/common-utils.h | 3 |
2 files changed, 21 insertions, 10 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index c0884de8a5e..f457c55df09 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -3634,6 +3634,24 @@ gf_skip_header_section (int fd, int header_len) return ret; } +/* Below function is use to check at runtime if pid is running */ + +gf_boolean_t +gf_is_pid_running (int pid) +{ + char fname[32] = {0,}; + + snprintf(fname, sizeof(fname), "/proc/%d/cmdline", pid); + + if (sys_access (fname , R_OK) != 0) { + return _gf_false; + } + + return _gf_true; + +} + + gf_boolean_t gf_is_service_running (char *pidfile, int *pid) { @@ -3662,15 +3680,7 @@ gf_is_service_running (char *pidfile, int *pid) *pid = -1; } - if (!*pid) { - /* - * PID 0 means we've started the process, but it hasn't gotten - * far enough to put in a real PID yet. More details are in - * glusterd_brick_start. - */ - running = _gf_true; - } - + running = gf_is_pid_running (*pid); out: if (file) fclose (file); diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h index 67baa852c45..6243732b522 100644 --- a/libglusterfs/src/common-utils.h +++ b/libglusterfs/src/common-utils.h @@ -821,7 +821,8 @@ int gf_thread_create (pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg); int gf_thread_create_detached (pthread_t *thread, void *(*start_routine)(void *), void *arg); - +gf_boolean_t +gf_is_pid_running (int pid); gf_boolean_t gf_is_service_running (char *pidfile, int *pid); gf_boolean_t |