Skip to content

Commit

Permalink
WIP print child exit code
Browse files Browse the repository at this point in the history
Change-Id: I188923efc0f72b2038f1470740415ce50d07580b
Signed-off-by: Arne Schwabe <[email protected]>
  • Loading branch information
schwabe committed Jan 14, 2025
1 parent ad0d949 commit eb26588
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/openvpn/tun_afunix.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,31 @@
#include <signal.h>
#include <stdlib.h>

static void
child_handler(int sig)
{
int status;
pid_t pid;

/* EEEEXTEERMINAAATE! */
while ((pid = 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 = 0;
sa.sa_handler = child_handler;

sigaction(SIGCHLD, &sa, NULL);
}

static void
tun_afunix_exec_child(const char *dev_node, struct tuntap *tt, struct env_set *env)
{
Expand All @@ -59,10 +84,13 @@ tun_afunix_exec_child(const char *dev_node, struct tuntap *tt, struct env_set *e
argv_printf(&argv, "%s", program);

argv_msg(M_INFO, &argv);

enable_signal_handler();
tt->afunix.childprocess = openvpn_execve_check(&argv, env, S_NOWAITPID,
"ERROR: failure executing "
"process for tun");
argv_free(&argv);

}

void
Expand Down Expand Up @@ -120,6 +148,8 @@ open_tun_afunix(struct options *o,
gc_free(&gc);
}



void
close_tun_afunix(struct tuntap *tt)
{
Expand Down

0 comments on commit eb26588

Please sign in to comment.