Skip to content

Commit

Permalink
GUACAMOLE-1841: Ensure that children get killed even under windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmuehlner committed Oct 17, 2023
1 parent b845e18 commit b368a0a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/guacd/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include <io.h>
#include <handleapi.h>
#include <sys/cygwin.h>
#include <stdio.h>
#endif

/**
Expand Down Expand Up @@ -363,6 +364,13 @@ guacd_proc* guacd_proc_self = NULL;
*/
static void signal_stop_handler(int signal) {

#ifdef CYGWIN_BUILD
/* Convert to a windows PID for logging */
pid_t windows_pid = cygwin_internal(CW_CYGWIN_PID_TO_WINPID, guacd_proc_self->pid);
fprintf(stderr, "I caught signal %i and am accordingly killing self with cyg %i, win %i\n",
signal, guacd_proc_self->pid, windows_pid);
#endif

/* Stop the current guacd proc */
guacd_proc_stop(guacd_proc_self);

Expand Down Expand Up @@ -579,6 +587,14 @@ guacd_proc* guacd_create_proc(const char* protocol) {
*/
static void guacd_proc_kill(guacd_proc* proc) {


#ifdef CYGWIN_BUILD
pid_t windows_pid = cygwin_internal(CW_CYGWIN_PID_TO_WINPID, proc->pid);

guacd_log(GUAC_LOG_DEBUG, "Trying to kill child - cyg: %i, win: %i", proc->pid, windows_pid);
#endif


/* Request orderly termination of process */
if (kill(proc->pid, SIGTERM))
guacd_log(GUAC_LOG_DEBUG, "Unable to request termination of "
Expand Down

0 comments on commit b368a0a

Please sign in to comment.