summaryrefslogtreecommitdiff
path: root/accel-pppd/main.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-12-26 20:59:35 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-12-26 20:59:35 +0300
commita60cf6e994a658a3cb20d1446831ea6e2c673715 (patch)
treeb7e862ede642871046882f58dfba64f31ad8bd3a /accel-pppd/main.c
parentc767ca5d3c09d8f64dbfa05e86fde1fd5d702083 (diff)
downloadaccel-ppp-a60cf6e994a658a3cb20d1446831ea6e2c673715.tar.gz
accel-ppp-a60cf6e994a658a3cb20d1446831ea6e2c673715.zip
get rid of deprecated readdir_r
Diffstat (limited to 'accel-pppd/main.c')
-rw-r--r--accel-pppd/main.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/accel-pppd/main.c b/accel-pppd/main.c
index 0f85c771..298e0391 100644
--- a/accel-pppd/main.c
+++ b/accel-pppd/main.c
@@ -111,9 +111,9 @@ static void config_reload(int num)
static void close_all_fd(void)
{
DIR *dirp;
- struct dirent ent, *res;
+ struct dirent *ent;
char path[128];
- int fd;
+ int fd, dir_fd;
sprintf(path, "/proc/%u/fd", getpid());
@@ -121,14 +121,15 @@ static void close_all_fd(void)
if (!dirp)
return;
+ dir_fd = dirfd(dirp);
+
while (1) {
- if (readdir_r(dirp, &ent, &res))
- return;
- if (!res)
+ ent = readdir(dirp);
+ if (!ent)
break;
- fd = atol(ent.d_name);
- if (fd > 2)
+ fd = atol(ent->d_name);
+ if (fd > 2 && fd != dir_fd)
close(fd);
}