diff mbox series

[1/8] core: warn about non-Linux parent SIGTERM tracking

Message ID 20180423123109.18590-1-christian.storm@siemens.com
State Accepted
Headers show
Series [1/8] core: warn about non-Linux parent SIGTERM tracking | expand

Commit Message

Storm, Christian April 23, 2018, 12:31 p.m. UTC
As prctl(2) and hence SIGUSR1 tracking is only available
on Linux, issue a warning on non-Linux OSes.

Signed-off-by: Thomas Zander <thomas.zander@siemens.com>
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 core/pctl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Stefano Babic April 23, 2018, 5:54 p.m. UTC | #1
On 23/04/2018 14:31, Christian Storm wrote:
> As prctl(2) and hence SIGUSR1 tracking is only available
> on Linux, issue a warning on non-Linux OSes.
> 
> Signed-off-by: Thomas Zander <thomas.zander@siemens.com>
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  core/pctl.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/core/pctl.c b/core/pctl.c
> index e35741b..121559e 100644
> --- a/core/pctl.c
> +++ b/core/pctl.c
> @@ -10,7 +10,9 @@
>  #include <unistd.h>
>  #include <sys/types.h>
>  #include <sys/socket.h>
> +#if defined(__linux__)
>  #include <sys/prctl.h>
> +#endif
>  #include <errno.h>
>  #include <pthread.h>
>  #include <network_ipc.h>
> @@ -135,6 +137,7 @@ static int spawn_process(struct swupdate_task *task,
>  
>  	notify_init();
>  
> +#if defined(__linux__)
>  	if (signal(SIGUSR1, parent_dead_handler) == SIG_ERR) {
>  		/*
>  		 * this is not a reason to break, just a warning
> @@ -143,7 +146,10 @@ static int spawn_process(struct swupdate_task *task,
>  	}
>  
>  	if (prctl(PR_SET_PDEATHSIG, SIGUSR1) < 0)
> -		ERROR("Fail to call prctl, maybe not Linux ?");
> +		ERROR("Error calling prctl");
> +#else
> +	WARN("Cannot track if parent dies on non-Linux OSes, sorry...");
> +#endif
>  
>  	if (start)
>  		return (*start)(cfgname, ac, av);
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/core/pctl.c b/core/pctl.c
index e35741b..121559e 100644
--- a/core/pctl.c
+++ b/core/pctl.c
@@ -10,7 +10,9 @@ 
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#if defined(__linux__)
 #include <sys/prctl.h>
+#endif
 #include <errno.h>
 #include <pthread.h>
 #include <network_ipc.h>
@@ -135,6 +137,7 @@  static int spawn_process(struct swupdate_task *task,
 
 	notify_init();
 
+#if defined(__linux__)
 	if (signal(SIGUSR1, parent_dead_handler) == SIG_ERR) {
 		/*
 		 * this is not a reason to break, just a warning
@@ -143,7 +146,10 @@  static int spawn_process(struct swupdate_task *task,
 	}
 
 	if (prctl(PR_SET_PDEATHSIG, SIGUSR1) < 0)
-		ERROR("Fail to call prctl, maybe not Linux ?");
+		ERROR("Error calling prctl");
+#else
+	WARN("Cannot track if parent dies on non-Linux OSes, sorry...");
+#endif
 
 	if (start)
 		return (*start)(cfgname, ac, av);