]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-linux.c
pppd: Be sure to close /dev/ppp when reconnecting (#184)
[ppp.git] / pppd / sys-linux.c
index 28bc4be1a689681e400b14bb4d4226898d75e992..587242bb1ed7a2cb0107061a2109e17ccdde1dd1 100644 (file)
@@ -467,6 +467,13 @@ int generic_establish_ppp (int fd)
     if (new_style_driver) {
        int flags;
 
+       /* If a ppp_fd is already open, close it first */
+       if (ppp_fd >= 0) {
+           close(ppp_fd);
+           remove_fd(ppp_fd);
+           ppp_fd = -1;
+       }
+
        /* Open an instance of /dev/ppp and connect the channel to it */
        if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) {
            error("Couldn't get channel number: %m");