From ff9e32bb80b2f88fe42be57a8fa33208b8c0af95 Mon Sep 17 00:00:00 2001 From: "M. Vefa Bicakci" Date: Tue, 6 Jul 2021 10:50:34 -0400 Subject: [PATCH] sm_process_death: Avoid redefinition errors due to kernel headers Prior to the v5.10-based StarlingX kernel, the "#ifdef CONFIG_SIGEXIT" guard in prctl.h would require the user-space to either define the CONFIG_SIGEXIT macro, or define the PR_DO_NOTIFY_TASK_STATE macro *and* the task_state_notify_info structure to avoid build failures. The service manager code had taken the latter approach. Now that the prctl.h header file has been fixed in the v5.10-based kernel to not guard these user-space APIs with "#ifdef CONFIG_SIGEXIT", the service manager is encountering the following compilation errors: sm_process_death.c:49:8: error: redefinition of \ 'struct task_state_notify_info' struct task_state_notify_info ^ In file included from /usr/include/sys/prctl.h:22:0, from sm_process_death.c:18: /usr/include/linux/prctl.h:76:8: error: previous definition of \ 'struct task_state_notify_info' struct task_state_notify_info { ^ This commit avoids these errors by detecting whether the PR_DO_NOTIFY_TASK_STATE macro has already been defined, which ought to preserve backwards compatibility with older StarlingX kernels. Story: 2008921 Change-Id: I0c28fe8b3d314931583462a3377f81ec0ca1f630 Signed-off-by: M. Vefa Bicakci --- service-mgmt/sm/src/sm_process_death.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/service-mgmt/sm/src/sm_process_death.c b/service-mgmt/sm/src/sm_process_death.c index 8198608b..7d520a76 100644 --- a/service-mgmt/sm/src/sm_process_death.c +++ b/service-mgmt/sm/src/sm_process_death.c @@ -35,23 +35,28 @@ #define SM_KERNEL_NOTIFY_FLAGS \ ( SM_KERNEL_NOTIFY_EXITED | SM_KERNEL_NOTIFY_KILLED ) +#define SM_KERNEL_NOTIFY_SIGNAL (SIGRTMIN+1) + +// Avoid redefinition errors for PR_DO_NOTIFY_TASK_STATE macro and +// task_state_notify_info struct as the kernel headers may have +// already defined them. +#ifndef PR_DO_NOTIFY_TASK_STATE // Set/get notification for task state changes. #define PR_DO_NOTIFY_TASK_STATE 17 -#define SM_KERNEL_NOTIFY_SIGNAL (SIGRTMIN+1) - // This is the data structure for requestion process death // (and other state change) information. Sig of -1 means // query, sig of 0 means deregistration, positive sig means // that you want to set it. sig and events are value-result // and will be updated with the previous values on every // successful call. -struct task_state_notify_info +struct task_state_notify_info { pid_t pid; - int sig; - unsigned int events; + int sig; + unsigned int events; }; +#endif // !PR_DO_NOTIFY_TASK_STATE #endif // __SM_PROCESS_DEATH_KERNEL_NOTIFICATION_SUPPORTED__ #define SM_PROCESS_DEATH_MAX 1024