diff --git a/daemon/cmd_stop_studio.c b/daemon/cmd_stop_studio.c index e085e153..9037f24a 100644 --- a/daemon/cmd_stop_studio.c +++ b/daemon/cmd_stop_studio.c @@ -28,9 +28,11 @@ #include "cmd.h" #include "studio_internal.h" +#include "loader.h" #define STOP_STATE_WAITING_FOR_JACK_CLIENTS_DISAPPEAR 1 -#define STOP_STATE_WAITING_FOR_JACK_SERVER_STOP 2 +#define STOP_STATE_WAITING_FOR_CHILDS_TERMINATION 2 +#define STOP_STATE_WAITING_FOR_JACK_SERVER_STOP 3 struct ladish_command_stop_studio { @@ -75,6 +77,18 @@ static bool run(void * context) return true; } + cmd_ptr->stop_state = STOP_STATE_WAITING_FOR_CHILDS_TERMINATION; + } + + if (cmd_ptr->stop_state == STOP_STATE_WAITING_FOR_CHILDS_TERMINATION) + { + clients_count = loader_get_app_count(); + log_info("%u child processes are running", clients_count); + if (clients_count != 0) + { + return true; + } + log_info("Stopping JACK server..."); ladish_graph_dump(g_studio.studio_graph); diff --git a/daemon/loader.c b/daemon/loader.c index 3ecf37c6..e3abd5eb 100644 --- a/daemon/loader.c +++ b/daemon/loader.c @@ -564,3 +564,18 @@ free_struct: fail: return false; } + +unsigned int loader_get_app_count(void) +{ + struct list_head * node_ptr; + unsigned int count; + + count = 0; + + list_for_each(node_ptr, &g_childs_list) + { + count++; + } + + return count; +} diff --git a/daemon/loader.h b/daemon/loader.h index 4cb1cedb..94fa4db6 100644 --- a/daemon/loader.h +++ b/daemon/loader.h @@ -42,4 +42,6 @@ void loader_run(void); void loader_uninit(void); +unsigned int loader_get_app_count(void); + #endif /* __LASHD_LOADER_H__ */