char logpath[PATH_MAX];
sigset_t mask;
char *lxcpath = argv[1];
+ bool mainloop_opened = false;
+ bool monitord_created = false;
if (argc != 3) {
fprintf(stderr,
ERROR("Failed to create mainloop.");
goto on_error;
}
+ mainloop_opened = true;
- if (lxc_monitord_create(&mon)) {
+ if (lxc_monitord_create(&mon))
goto on_error;
- }
+ monitord_created = true;
/* sync with parent, we're ignoring the return from write
* because regardless if it works or not, the following
}
}
- lxc_mainloop_close(&mon.descr);
- lxc_monitord_cleanup();
+on_signal:
ret = EXIT_SUCCESS;
-
on_error:
- exit(ret);
+ if (monitord_created)
+ lxc_monitord_cleanup();
+ if (mainloop_opened)
+ lxc_mainloop_close(&mon.descr);
-on_signal:
- lxc_monitord_cleanup();
- exit(EXIT_SUCCESS);
+ exit(ret);
}
}
if (pid2) {
+ DEBUG("Trying to sync with child process.");
char c;
/* Wait for daemon to create socket. */
close(pipefd[1]);
close(pipefd[0]);
+ DEBUG("Sucessfully synced with child process.");
exit(EXIT_SUCCESS);
}