diff mbox

linux-gen: _fdserver: request sigterm if parent dies

Message ID 1480082504-16506-1-git-send-email-christophe.milard@linaro.org
State Superseded
Headers show

Commit Message

Christophe Milard Nov. 25, 2016, 2:01 p.m. UTC
_fdserver now request SIGTERM if parent process (ODP instantiation
process) dies, hence avoiding it to become orphan and reattached to the
init process.

Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

---
 platform/linux-generic/_fdserver.c | 6 ++++++
 1 file changed, 6 insertions(+)

-- 
2.7.4

Comments

Christophe Milard Nov. 25, 2016, 1:14 p.m. UTC | #1
Please ignore: this is meant for API-NEXt!: sending a new one!


On 25 November 2016 at 15:01, Christophe Milard
<christophe.milard@linaro.org> wrote:
> _fdserver now request SIGTERM if parent process (ODP instantiation

> process) dies, hence avoiding it to become orphan and reattached to the

> init process.

>

> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

> ---

>  platform/linux-generic/_fdserver.c | 6 ++++++

>  1 file changed, 6 insertions(+)

>

> diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c

> index 41a630b..9aed7a9 100644

> --- a/platform/linux-generic/_fdserver.c

> +++ b/platform/linux-generic/_fdserver.c

> @@ -41,6 +41,8 @@

>  #include <odp_internal.h>

>  #include <odp_debug_internal.h>

>  #include <_fdserver_internal.h>

> +#include <sys/prctl.h>

> +#include <signal.h>

>

>  #include <stdio.h>

>  #include <stdlib.h>

> @@ -622,6 +624,10 @@ int _odp_fdserver_init_global(void)

>                 /* TODO: pin the server on appropriate service cpu mask */

>                 /* when (if) we can agree on the usage of service mask  */

>

> +               /* request to be killed if parent dies, hence avoiding  */

> +               /* orphans being "adopted" by the init process...       */

> +               prctl(PR_SET_PDEATHSIG, SIGTERM);

> +

>                 /* allocate the space for the file descriptor<->key table: */

>                 fd_table = malloc(FDSERVER_MAX_ENTRIES * sizeof(fdentry_t));

>                 if (!fd_table) {

> --

> 2.7.4

>
Mike Holmes Dec. 1, 2016, 7:10 p.m. UTC | #2
On 25 November 2016 at 09:01, Christophe Milard <
christophe.milard@linaro.org> wrote:

> _fdserver now request SIGTERM if parent process (ODP instantiation

> process) dies, hence avoiding it to become orphan and reattached to the

> init process.

>

> Signed-off-by: Christophe Milard <christophe.milard@linaro.org>

>


Reviewed-by: Mike Holmes <mike.holmes@linaro.,org>



> ---

>  platform/linux-generic/_fdserver.c | 6 ++++++

>  1 file changed, 6 insertions(+)

>

> diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_

> fdserver.c

> index 41a630b..9aed7a9 100644

> --- a/platform/linux-generic/_fdserver.c

> +++ b/platform/linux-generic/_fdserver.c

> @@ -41,6 +41,8 @@

>  #include <odp_internal.h>

>  #include <odp_debug_internal.h>

>  #include <_fdserver_internal.h>

> +#include <sys/prctl.h>

> +#include <signal.h>

>

>  #include <stdio.h>

>  #include <stdlib.h>

> @@ -622,6 +624,10 @@ int _odp_fdserver_init_global(void)

>                 /* TODO: pin the server on appropriate service cpu mask */

>                 /* when (if) we can agree on the usage of service mask  */

>

> +               /* request to be killed if parent dies, hence avoiding  */

> +               /* orphans being "adopted" by the init process...       */

> +               prctl(PR_SET_PDEATHSIG, SIGTERM);

> +

>                 /* allocate the space for the file descriptor<->key table:

> */

>                 fd_table = malloc(FDSERVER_MAX_ENTRIES *

> sizeof(fdentry_t));

>                 if (!fd_table) {

> --

> 2.7.4

>

>



-- 
Mike Holmes
Program Manager - Linaro Networking Group
Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
"Work should be fun and collaborative, the rest follows"
diff mbox

Patch

diff --git a/platform/linux-generic/_fdserver.c b/platform/linux-generic/_fdserver.c
index 41a630b..9aed7a9 100644
--- a/platform/linux-generic/_fdserver.c
+++ b/platform/linux-generic/_fdserver.c
@@ -41,6 +41,8 @@ 
 #include <odp_internal.h>
 #include <odp_debug_internal.h>
 #include <_fdserver_internal.h>
+#include <sys/prctl.h>
+#include <signal.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -622,6 +624,10 @@  int _odp_fdserver_init_global(void)
 		/* TODO: pin the server on appropriate service cpu mask */
 		/* when (if) we can agree on the usage of service mask  */
 
+		/* request to be killed if parent dies, hence avoiding  */
+		/* orphans being "adopted" by the init process...	*/
+		prctl(PR_SET_PDEATHSIG, SIGTERM);
+
 		/* allocate the space for the file descriptor<->key table: */
 		fd_table = malloc(FDSERVER_MAX_ENTRIES * sizeof(fdentry_t));
 		if (!fd_table) {