From 6b8303caf3c5c70ae1c1d362bf6de0c55eb622bb Mon Sep 17 00:00:00 2001 From: Alexandre Chartre Date: Tue, 10 Nov 2009 14:23:17 -0800 Subject: 6892130 ldmad can fail to daemonize 6898423 misc minor errors in ldmad --- usr/src/cmd/ldmad/ldma.h | 8 ++++---- usr/src/cmd/ldmad/ldma_device.c | 2 +- usr/src/cmd/ldmad/ldmad.c | 14 ++++++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'usr/src') diff --git a/usr/src/cmd/ldmad/ldma.h b/usr/src/cmd/ldmad/ldma.h index 92abc954ee..0ddf65a5dd 100644 --- a/usr/src/cmd/ldmad/ldma.h +++ b/usr/src/cmd/ldmad/ldma.h @@ -27,14 +27,14 @@ #ifndef _LDMA_H #define _LDMA_H -#ifdef __cplusplus -extern "C" { -#endif - #include #include #include +#ifdef __cplusplus +extern "C" { +#endif + /* * The following definitions are part of the LDoms Agent specification. */ diff --git a/usr/src/cmd/ldmad/ldma_device.c b/usr/src/cmd/ldmad/ldma_device.c index 94e4831262..1a73d7743d 100644 --- a/usr/src/cmd/ldmad/ldma_device.c +++ b/usr/src/cmd/ldmad/ldma_device.c @@ -140,7 +140,7 @@ ldma_dev_validate_path(ds_ver_t *ver, ldma_message_header_t *request, reply->msg_info |= LDMA_DEVPATH_EXIST; - LDMA_DBG("VALIDATE_PATH(%s): file mode = 0x%x", path, st.st_mode); + LDMA_DBG("VALIDATE_PATH(%s): file mode = 0x%lx", path, st.st_mode); switch (st.st_mode & S_IFMT) { diff --git a/usr/src/cmd/ldmad/ldmad.c b/usr/src/cmd/ldmad/ldmad.c index 2403cd2cd7..8b5ccf41bf 100644 --- a/usr/src/cmd/ldmad/ldmad.c +++ b/usr/src/cmd/ldmad/ldmad.c @@ -88,7 +88,7 @@ static ldma_agent_info_t *ldma_agent_infos[] = { }; static char *cmdname; -static pid_t daemon_pid; +static pid_t daemon_pid = 0; /* * Allocate a new message with the specified message number (msg_num), @@ -377,8 +377,14 @@ ldma_register_agents() static void ldma_sigusr_handler(int sig, siginfo_t *sinfo, void *ucontext) { - if (daemon_pid <= 0 || sig != SIGUSR1 || sinfo->si_code != SI_USER || - sinfo->si_pid != daemon_pid) + /* + * The child process can send the signal before the fork() + * call has returned in the parent process. So daemon_pid + * may not be set yet, and we don't check the pid in that + * case. + */ + if (sig != SIGUSR1 || sinfo->si_code != SI_USER || + (daemon_pid > 0 && sinfo->si_pid != daemon_pid)) return; /* @@ -499,7 +505,7 @@ ldma_start(boolean_t standalone) */ if (ldma_register_agents() == 0) { /* no agent registered */ - LDMA_ERR("Unable to register any agent", cmdname); + LDMA_ERR("Unable to register any agent"); exit(1); } -- cgit v1.2.3