EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Creating Zombies with epicsThreadExitMain
From: Andrew Johnson <[email protected]>
To: Michael Abbott <[email protected]>
Cc: [email protected]
Date: Mon, 12 May 2008 10:41:03 -0500
Michael Abbott wrote:
I guess there are two separate issues here:

1. Exiting with epicsThreadExitMain() appears to be a very bad thing, at least on RHEL;

The whole point of the routine epicsThreadExitMain() is to arrange for the main thread to complete _without_ shutting down the other threads om the process. If you want to shut down an IOC completely, you have to call epicsExit() instead. The softIoc implementation will do this if you tell it to start an interactive shell (use the -s option in R3.14.9; in R3.14.10 -s does nothing and the default is to start a shell unless you explicitly say -S).


If you don't ask for an interactive shell there's nothing for the main thread to do after loading databases so it calls epicsThreadExitMain(). At this point the process looks like a zombie, but it has many other threads still running (ls /proc/<pid>/task). If you kill -9 one of these other threads the whole process should shut down and the zombie goes away.

If you want to be able to shut down a softIoc using Control-C, you have to start an interactive shell. If you want to be able to shut down a softIoc that has no interactive shell, load the softIocExit.db and do a caput to its $(IOC):exit PV which causes epicsExit() to be called.

2. RHEL appears to have an unpleasant bug involving process cleanup -- how else do I have persistent zombies owned by init? Or else I'm missing something...

See above, there are still other threads running in the process.


The iocsh() call is necessary to reproduce the problem.
...
Curious. I would have expected the _exit(0) call to have done everything that's necessary. As far as I can tell from the man page, _exit is pretty well guaranteed to terminate the program.

The _exit() call does not trigger the atexit() callbacks which trigger the shutting down of the other threads. In your example, iocsh() calls errlogFlush() which calls errloginit() which starts the errlog thread. This initialization is rather unfortunate, but it would take some work to arrange for the errlog thread to only be started when there is actually some work for it to do. I would love to see that done if someone wants to take it on.


HTH,

- Andrew
--
Talk is cheap. Show me the code. -- Linus Torvalds

Replies:
Re: Creating Zombies with epicsThreadExitMain Michael Abbott
References:
Creating Zombies with epicsThreadExitMain Michael Abbott
Re: Creating Zombies with epicsThreadExitMain Michael Abbott

Navigate by Date:
Prev: Re: Creating Zombies with epicsThreadExitMain Michael Abbott
Next: RE: Creating Zombies with epicsThreadExitMain Pearson, MR (Matthew)
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Creating Zombies with epicsThreadExitMain Michael Abbott
Next: Re: Creating Zombies with epicsThreadExitMain Michael Abbott
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  <20082009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·