summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5df0f28)
Using lttng cli, if the session daemon dies after exec(), a SIGCHLD is
returned. It was catched but not handled to cleanly quit and inform the
user that the session daemon failed.
We now use SIGUSR1 to signal the lttng cli that the session daemon is
ready to receive command.
Signed-off-by: David Goulet <dgoulet@efficios.com>
* Notify parent pid that we are ready to accept command for client side.
*/
if (opt_sig_parent) {
* Notify parent pid that we are ready to accept command for client side.
*/
if (opt_sig_parent) {
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <unistd.h>
#include <config.h>
#include <unistd.h>
#include <config.h>
int opt_verbose;
static int opt_no_sessiond;
static char *opt_sessiond_path;
int opt_verbose;
static int opt_no_sessiond;
static char *opt_sessiond_path;
+static pid_t sessiond_pid;
*/
static void sighandler(int sig)
{
*/
static void sighandler(int sig)
{
switch (sig) {
case SIGTERM:
DBG("SIGTERM caugth");
clean_exit(EXIT_FAILURE);
break;
case SIGCHLD:
switch (sig) {
case SIGTERM:
DBG("SIGTERM caugth");
clean_exit(EXIT_FAILURE);
break;
case SIGCHLD:
+ waitpid(sessiond_pid, &status, 0);
+ /* Indicate that the session daemon died */
+ sessiond_pid = 0;
+ ERR("Session daemon died (exit status %d)", WEXITSTATUS(status));
+ break;
+ case SIGUSR1:
+ /* Notify is done */
+ DBG("SIGUSR1 caugth");
break;
default:
DBG("Unknown signal %d caugth", sig);
break;
default:
DBG("Unknown signal %d caugth", sig);
sa.sa_handler = sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
sa.sa_handler = sighandler;
sa.sa_mask = sigset;
sa.sa_flags = 0;
- if ((ret = sigaction(SIGCHLD, &sa, NULL)) < 0) {
+ if ((ret = sigaction(SIGUSR1, &sa, NULL)) < 0) {
perror("sigaction");
goto end;
}
perror("sigaction");
goto end;
}
+ if ((ret = sigaction(SIGCHLD, &sa, NULL)) < 0) {
+ perror("sigaction");
+ goto end;
+ }
+
kill(getppid(), SIGTERM); /* unpause parent */
exit(EXIT_FAILURE);
} else if (pid > 0) {
kill(getppid(), SIGTERM); /* unpause parent */
exit(EXIT_FAILURE);
} else if (pid > 0) {
/* Wait for lttng-sessiond to start */
pause();
/* Wait for lttng-sessiond to start */
pause();
+ if (!sessiond_pid) {
+ exit(EXIT_FAILURE);
+ }
goto end;
} else {
perror("fork");
goto end;
} else {
perror("fork");