aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-05-05 16:56:42 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-05-05 16:56:42 +0000
commit9698031becc026b69e0d205c066566ec8041655c (patch)
tree43958ec7dc6dc47e98b05e88edd03fbc433e193a
parentb8a49d3b901aa9b9095fa1b3049c1cb7b46a0436 (diff)
downloadupstream-9698031becc026b69e0d205c066566ec8041655c.tar.gz
upstream-9698031becc026b69e0d205c066566ec8041655c.tar.bz2
upstream-9698031becc026b69e0d205c066566ec8041655c.zip
pptp: kill the call manager process on shutdown
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31606 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r--package/pptp/patches/100-signal_cleanup.patch74
1 files changed, 74 insertions, 0 deletions
diff --git a/package/pptp/patches/100-signal_cleanup.patch b/package/pptp/patches/100-signal_cleanup.patch
new file mode 100644
index 0000000000..cb3a94f2ad
--- /dev/null
+++ b/package/pptp/patches/100-signal_cleanup.patch
@@ -0,0 +1,74 @@
+--- a/pptp.c
++++ b/pptp.c
+@@ -60,6 +60,7 @@
+ int syncppp = 0;
+ int log_level = 1;
+ int disable_buffer = 0;
++pid_t callmgr_pid = 0;
+
+ struct in_addr get_ip_address(char *name);
+ int open_callmgr(struct in_addr inetaddr, char *phonenr, int argc,char **argv,char **envp, int pty_fd, int gre_fd);
+@@ -115,6 +116,8 @@ sigjmp_buf env;
+ /*** signal handler ***********************************************************/
+ void sighandler(int sig)
+ {
++ fprintf(stderr, "Got signal, pid=%d\n", callmgr_pid);
++ fflush(stderr);
+ siglongjmp(env, 1);
+ }
+
+@@ -330,6 +333,14 @@ int main(int argc, char **argv, char **e
+ parent_pid = 0; /* don't kill pppd */
+ }
+
++ if (sigsetjmp(env, 1)!= 0) goto shutdown;
++
++ signal(SIGINT, sighandler);
++ signal(SIGTERM, sighandler);
++ signal(SIGKILL, sighandler);
++ signal(SIGCHLD, sighandler);
++ signal(SIGUSR1, sigstats);
++
+ do {
+ /*
+ * Open connection to call manager (Launch call manager if necessary.)
+@@ -360,13 +371,6 @@ int main(int argc, char **argv, char **e
+ if (rc != 0) perror("prctl");
+ #endif
+ inststr(argc, argv, envp, buf);
+- if (sigsetjmp(env, 1)!= 0) goto shutdown;
+-
+- signal(SIGINT, sighandler);
+- signal(SIGTERM, sighandler);
+- signal(SIGKILL, sighandler);
+- signal(SIGCHLD, sighandler);
+- signal(SIGUSR1, sigstats);
+
+ /* Do GRE copy until close. */
+ pptp_gre_copy(call_id, peer_call_id, pty_fd, gre_fd);
+@@ -375,6 +379,8 @@ shutdown:
+ /* on close, kill all. */
+ if(launchpppd)
+ kill(parent_pid, SIGTERM);
++ if (callmgr_pid)
++ kill(callmgr_pid, SIGTERM);
+ close(pty_fd);
+ close(callmgr_sock);
+ exit(0);
+@@ -407,7 +413,7 @@ int open_callmgr(struct in_addr inetaddr
+ struct sockaddr_un where;
+ const int NUM_TRIES = 3;
+ int i, fd;
+- pid_t pid;
++ pid_t pid = 0;
+ int status;
+ /* Open socket */
+ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
+@@ -434,6 +440,7 @@ int open_callmgr(struct in_addr inetaddr
+ launch_callmgr(inetaddr, phonenr, argc, argv, envp);
+ }
+ default: /* parent */
++ callmgr_pid = pid;
+ waitpid(pid, &status, 0);
+ if (status!= 0)
+ fatal("Call manager exited with error %d", status);