Index: src_plugins/hid_srv_ws/server.c =================================================================== --- src_plugins/hid_srv_ws/server.c (revision 10626) +++ src_plugins/hid_srv_ws/server.c (revision 10627) @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include "plugins.h" @@ -265,7 +267,24 @@ return 0; } +static void srv_ws_sigchld(int sig) +{ + pid_t p; + int st; + hid_srv_ws_t *ctx = &hid_srv_ws_ctx; + hid_srv_ws_client_t *cl; + p = wait(&st); + + cl = htip_get(&ctx->clients, p); + if (cl != NULL) { + ctx->num_clients--; + htip_pop(&ctx->clients, p); + pcb_message(PCB_MSG_INFO, "websocket [%d]: sigchld ack'd\n", p); + free(cl); + } +} + static int srv_ws_listen(hid_srv_ws_t *ctx) { @@ -298,6 +317,7 @@ htip_init(&ctx->clients, longhash, longkeyeq); htip_init(&ctx->fd_lookup, longhash, longkeyeq); + signal(SIGCHLD, srv_ws_sigchld); /* create lws context representing this server */ ctx->context = lws_create_context(&context_info);