summaryrefslogtreecommitdiffstats
path: root/geo-replication/src/procdiggy.c
diff options
context:
space:
mode:
Diffstat (limited to 'geo-replication/src/procdiggy.c')
-rw-r--r--geo-replication/src/procdiggy.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/geo-replication/src/procdiggy.c b/geo-replication/src/procdiggy.c
index 1ea52c1a6a1..35125d20ba8 100644
--- a/geo-replication/src/procdiggy.c
+++ b/geo-replication/src/procdiggy.c
@@ -86,6 +86,7 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data),
char *name = NULL;
DIR *d = NULL;
struct dirent *de = NULL;
+ struct dirent scratch[2] = {{0,},};
pid_t pid = -1;
pid_t ppid = -1;
int ret = 0;
@@ -93,7 +94,13 @@ prociter (int (*proch) (pid_t pid, pid_t ppid, char *tmpname, void *data),
d = sys_opendir (PROC);
if (!d)
return -1;
- while (errno = 0, de = sys_readdir (d)) {
+
+ for (;;) {
+ errno = 0;
+ de = sys_readdir (d, scratch);
+ if (!de || errno != 0)
+ break;
+
if (gf_string2int (de->d_name, &pid) != -1 && pid >= 0) {
ppid = pidinfo (pid, &name);
switch (ppid) {