From: "plaisthos (Code Review)" Date: Tue, 24 Sep 2024 08:26:40 +0000 References: Reply-To: arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="0h3VTt3HlQM="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: WIP print child exit code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld Cc: openvpn-devel --0h3VTt3HlQM= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld. Hello flichtenheld, I'd like you to do a code review. Please visit http://gerrit.openvpn.net/c/openvpn/+/767?usp=3Demail to review the following change. Change subject: WIP print child exit code ...................................................................... WIP print child exit code Change-Id: I188923efc0f72b2038f1470740415ce50d07580b Signed-off-by: Arne Schwabe --- M src/openvpn/tun_afunix.c 1 file changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/67/767/1 diff --git a/src/openvpn/tun_afunix.c b/src/openvpn/tun_afunix.c index a2d8552..e26e1d8 100644 --- a/src/openvpn/tun_afunix.c +++ b/src/openvpn/tun_afunix.c @@ -48,6 +48,31 @@ #include static void +child_handler(int sig) +{ + int status; + pid_t pid; + + /* EEEEXTEERMINAAATE! */ + while ((pid =3D waitpid(-1, &status, WNOHANG)) > 0) + { + msg(M_INFO, "Child process PID %d died with status code %d", pid, = status); + } +} + +static void +enable_signal_handler(void) +{ + /* Establish handler. */ + struct sigaction sa; + sigemptyset(&sa.sa_mask); + sa.sa_flags =3D 0; + sa.sa_handler =3D child_handler; + + sigaction(SIGCHLD, &sa, NULL); +} + +static void tun_afunix_exec_child(const char *dev_node, struct tuntap *tt, struct env_= set *env) { struct argv argv =3D argv_new(); @@ -59,10 +84,13 @@ argv_printf(&argv, "%s", program); argv_msg(M_INFO, &argv); + + enable_signal_handler(); tt->afunix.childprocess =3D openvpn_execve_check(&argv, env, S_NOWAITP= ID, "ERROR: failure executi= ng " "process for tun"); argv_free(&argv); + } void @@ -120,6 +148,8 @@ gc_free(&gc); } + + void close_tun_afunix(struct tuntap *tt) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/767?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I188923efc0f72b2038f1470740415ce50d07580b Gerrit-Change-Number: 767 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos Gerrit-Reviewer: flichtenheld Gerrit-CC: openvpn-devel Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --0h3VTt3HlQM= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld.

plaisthos would like flichtenheld to review this change.

Vi= ew Change

WIP print child exit code

Change-Id: I188923efc0f72b20= 38f1470740415ce50d07580b
Signed-off-by: Arne Schwabe <arne@...1227...= >
---
M src/openvpn/tun_afunix.c
1 file changed, 30 insertions(= +), 0 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvp=
n refs/changes/67/767/1
diff --git a/src/openvpn/tun_afunix.c b/src=
/openvpn/tun_afunix.c
index a2d8552..e26e1d8 100644<= br>--- a/src/openvpn/tun_afunix.c
+++ b/src/openvpn/t= un_afunix.c
@@ -48,6 +48,31 @@
#include &l= t;stdlib.h>

static void
+child_handler(int sig)
= +{
+ int status;
+ pid_t pid;
+
+ = /* EEEEXTEERMINAAATE! */
+ while ((pid =3D waitpid(-1, &status, WNOHANG)) > 0)
+ {
+ msg(M_INFO, "Child proces= s PID %d died with status code %d", pid, status);
+ }
+}
+static void
+enable_signal_handler(vo= id)
+{
+ /* Establish handler. */
+ struct sigaction sa;<= /span>
+ sigemptyset(&= ;sa.sa_mask);
+ sa= .sa_flags =3D 0;
+ = sa.sa_handler =3D child_handler;
+
+ s= igaction(SIGCHLD, &sa, NULL);
+}
+

+static void
<= span> tun_afunix_exec_child(const char *dev_node, struct tuntap *tt, struct= env_set *env)
{
struct argv argv =3D= argv_new();
@@ -59,10 +84,13 @@
argv_= printf(&argv, "%s", program);

argv_msg(M_INFO, &argv);
+
+ = enable_signal_handler();
tt->afunix.childprocess = =3D openvpn_execve_check(&argv, env, S_NOWAITPID,
= "ERROR: failure executi= ng "
= "process for tun");
argv_free(&argv);=
+
}=

void
@@ -120,6 +148,8 @= @
gc_free(&gc);
}

+
+
void
close_tun_afunix(struct tuntap *tt)
{
=

To view, visit change 767. To unsubscribe, or for help writi= ng mail filters, visit setti= ngs.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I188923efc0f72b2038f14707404= 15ce50d07580b
Gerrit-Change-Number: 767
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <arne-openvpn@...1711...= 27...>
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--0h3VTt3HlQM=--