protocol: cleanup process without hanging

This commit is contained in:
Shuanglei Tao
2019-05-11 09:48:16 +08:00
parent fc4e06b907
commit e73a8e8587
4 changed files with 37 additions and 5 deletions

View File

@@ -181,6 +181,15 @@ sig_handler(int sig) {
lwsl_notice("send ^C to force exit.\n");
}
void
sigchld_handler() {
pid_t pid;
int status = wait_proc(-1, &pid);
if (pid > 0) {
lwsl_notice("process exited with code %d, pid: %d\n", status, pid);
}
}
int
calc_command_start(int argc, char **argv) {
// make a copy of argc and argv
@@ -456,6 +465,7 @@ main(int argc, char **argv) {
signal(SIGINT, sig_handler); // ^C
signal(SIGTERM, sig_handler); // kill
signal(SIGCHLD, sigchld_handler);
context = lws_create_context(&info);
if (context == NULL) {