Skip to content

Commit

Permalink
wait child process to terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
iqqmuT authored and fabled committed Feb 19, 2018
1 parent 39d3628 commit a17f413
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bmd-streamer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ int main(int argc, char **argv)
libusb_context *ctx;
libusb_hotplug_callback_handle cbhandle;
const char *msg = NULL;
int i, r, ec = 0, opt, optindex;
int i, r, ec = 0, opt, optindex, status;

signal(SIGCHLD, reapchildren);
signal(SIGTERM, dostop);
Expand Down Expand Up @@ -1453,6 +1453,9 @@ int main(int argc, char **argv)
libusb_handle_events(ctx);

error:
// wait child process to terminate
while (waitpid(-1, &status, 0) != -1 || errno != ECHILD);

if (msg)
dlog(LOG_ERR, "failed to %s: %s", msg, libusb_error_name(r));
if (ctx)
Expand Down

0 comments on commit a17f413

Please sign in to comment.