diff mbox

[API-NEXT] linux-gen: _fdserver: request sigterm if parent dies

Message ID 1480084773-17817-1-git-send-email-christophe.milard@linaro.org
State Accepted
Commit 9c4d778148d514adf8586939123acdcdc022e8e5
Headers show

Commit Message

Christophe Milard Nov. 25, 2016, 2:39 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. 30, 2016, 8:34 a.m. UTC | #1
ping

This should be straightforward to review and would help (partly) avoiding
hanging processes when killing ODP (e.g. ctrl-C)
Thanks

On 2016-11-25 15:39, Christophe Milard 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 Nov. 30, 2016, 12:48 p.m. UTC | #2
Christophe

Do you have a way I can create the problem and then prove to myself you
fixed it by applying this?
Can I  CTRL C any of our apps ?

Mike

On 30 November 2016 at 03:34, Christophe Milard <
christophe.milard@linaro.org> wrote:

> ping

>

> This should be straightforward to review and would help (partly) avoiding

> hanging processes when killing ODP (e.g. ctrl-C)

> Thanks

>

> On 2016-11-25 15:39, Christophe Milard 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
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"
Maxim Uvarov Nov. 30, 2016, 1:59 p.m. UTC | #3
On 11/30/16 15:48, Mike Holmes wrote:
> Christophe

>

> Do you have a way I can create the problem and then prove to myself 

> you fixed it by applying this?

> Can I  CTRL C any of our apps ?

>

> Mike

>


yes, Mike, I asked for that change.

run something like  make check and watch for background processes with 
ps -ax
(without patch there has to process which hangs, after patch it works 
great according to my tests).

Maxim.


> On 30 November 2016 at 03:34, Christophe Milard 

> <christophe.milard@linaro.org <mailto:christophe.milard@linaro.org>> 

> wrote:

>

>     ping

>

>     This should be straightforward to review and would help (partly)

>     avoiding

>     hanging processes when killing ODP (e.g. ctrl-C)

>     Thanks

>

>     On 2016-11-25 15:39, Christophe Milard 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

>     <mailto: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

> 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"

>
Maxim Uvarov Dec. 6, 2016, 2:40 p.m. UTC | #4
Merged,

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


from email with API-NEXT tag.

Maxim.


On 11/30/16 15:48, Mike Holmes wrote:
> Christophe

> 

> Do you have a way I can create the problem and then prove to myself you

> fixed it by applying this?

> Can I  CTRL C any of our apps ?

> 

> Mike

> 

> On 30 November 2016 at 03:34, Christophe Milard

> <christophe.milard@linaro.org <mailto:christophe.milard@linaro.org>> wrote:

> 

>     ping

> 

>     This should be straightforward to review and would help (partly)

>     avoiding

>     hanging processes when killing ODP (e.g. ctrl-C)

>     Thanks

> 

>     On 2016-11-25 15:39, Christophe Milard 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

>     <mailto: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

> 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) {