ALT Linux Bugzilla
– Attachment 1208 Details for
Bug 8312
[patch] workaround for ppp-watch misbehaviour
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
[patch]
ppp-watch workaround
net-scripts-pppd_sigterm.patch (text/plain), 2.29 KB, created by
Michael Shigorin
on 2005-10-21 16:08:30 MSD
(
hide
)
Description:
ppp-watch workaround
Filename:
MIME Type:
Creator:
Michael Shigorin
Created:
2005-10-21 16:08:30 MSD
Size:
2.29 KB
patch
obsolete
>diff -ur net-scripts-0.4.9.1/src/ppp-watch.c net-scripts-0.4.9.1-lvu/src/ppp-watch.c >--- net-scripts-0.4.9.1/src/ppp-watch.c 2001-03-05 02:22:06 +0200 >+++ net-scripts-0.4.9.1-lvu/src/ppp-watch.c 2005-10-21 10:31:23 +0300 >@@ -75,6 +75,7 @@ > #include <sys/wait.h> > #include <termios.h> > #include <net/if.h> >+#include <glob.h> > > #include "shvar.h" > #include "alloc.h" >@@ -116,6 +117,43 @@ > } > > >+static int >+get_pppd_pid(char *device) { >+ int i; >+ glob_t globbuf; >+ int ge = glob("/proc/*/cmdline", 0, NULL, &globbuf); >+ if (!ge) { >+ for (i = 0; i < globbuf.gl_pathc; ++i) { >+ FILE *fcmdline; >+ char cmdline[1024]; // hope this will be enough >+ if (fcmdline = fopen(globbuf.gl_pathv[i], "r")) { >+ int num_read; >+ num_read = fread(cmdline, 1, 1024, fcmdline); >+ if (num_read > 0 && !strcmp(cmdline, "/usr/sbin/pppd")) { >+ int prev_linkname = 0; >+ char *p = cmdline; >+ while (*p && p - cmdline < 1024) { >+ if (prev_linkname && !strcmp(p, device)) { >+ int retval; >+ globbuf.gl_pathv[i][strlen(globbuf.gl_pathv[i])-8] = 0; >+ retval = atoi(globbuf.gl_pathv[i]+6); >+ globfree(&globbuf); >+ fclose(fcmdline); >+ return retval; >+ } >+ prev_linkname = !strcmp(p, "linkname"); >+ p += strlen(p) + 1; >+ } >+ } >+ fclose(fcmdline); >+ } >+ } >+ globfree(&globbuf); >+ return 0; >+ } >+ else >+ return -1; >+} > > static void > detach(int now, int parentExitCode, char *device) { >@@ -550,6 +588,20 @@ > if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; } > physicalDevice = pppLogicalToPhysical(&pppdPid, real_device); > if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; } >+ if (!pppdPid && get_pppd_pid(device)) >+ { >+ // We suspect that pppd is running, but haven't created >+ // .pid file yet. So we'll wait for 10 seconds, checking >+ // for .pid file every 10 milliseconds. >+ int i; >+ for (i = 0; i < 1000 && !pppdPid && get_pppd_pid(device) !=0 ; ++i) >+ { >+ usleep(10000); >+ physicalDevice = pppLogicalToPhysical(&pppdPid, real_device); >+ if (physicalDevice) { free(physicalDevice); physicalDevice = NULL; } >+ } >+ sleep(2); // Else pppd may hangup, seems there's a bug in it >+ } > if (!pppdPid) cleanExit(35); > kill(pppdPid, sendsig); > if (sendsig == SIGKILL) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 8312
:
1208
|
1230