diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2017-12-26 20:59:35 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2017-12-26 20:59:35 +0300 |
commit | a60cf6e994a658a3cb20d1446831ea6e2c673715 (patch) | |
tree | b7e862ede642871046882f58dfba64f31ad8bd3a /accel-pppd/main.c | |
parent | c767ca5d3c09d8f64dbfa05e86fde1fd5d702083 (diff) | |
download | accel-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.c | 15 |
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); } |