[master 00/17] Improve child process starting and management

David Shea dshea at redhat.com
Sun Sep 21 19:36:52 UTC 2014


The overall goal is to ensure that any time we start a new process, it should
be started with a clean set of signal handlers (in particular, make sure that
SIGPIPE is set to SIG_DFL instead of the SIG_IGN set by python) and no file
descriptors from the parent make it through exec() other than stdin, stdout and
stderr.

The first five are cleanups in the main anaconda script that I hope will be
uncontroversial, one of them obviously a typo that I pushed a couple weeks
ago. Oops.

Patches 6, 7, and 15 are related to the SIGCHLD handler. We don't want to throw
an exception if X or metacity exits before anaconda during a reboot, so clear
the watched process list in exitHandler. Patch 6 rearranges the anaconda script
in order to catch exceptions from watched processes, so we can do the ipmi
stuff when X crashes. Patch 15 moves the watch methods into iutil and modifies
them to use Popen objects instead of a custom fork-exec protocol.

The "Simplify iutil.execReadlines" patch we've discussed before, I've just
split the bits not directly related to execReadlines into separate commits and
expanded the commit message to hopefully explain and address the concerns from
last time. The rest of the patches are for creating a process starting
interface flexible enough for all of our process starts, and getting everyone
to use it.

I'm not real happy about patch 7, but I think we ought to do something in order
to send the ipmi report. Some discussion points:

  - I went with raise instead of sys.exit because I thought it would be
    unhelpful if anaconda rebooted in such a case. Is there something better
    we could do?
  - Should we catch Exception, instead? I don't think we do any ipmi stuff if
    something crashes and we get a meh handler, but I'm not 100% sure about
    that. ExitErrors will always be delivered to the main thread, but if we
    catch Exception, would we need a handler in the threading module as well?
  - None of this ever actually gets called, because gdk calls _exit(1) (!!)
    when it loses the X connection. How do we work around that?
      * If we override the error handlers with our own XSetErrorHandler and
        XSetIOErrorHandler calls, there will still be a gap between Gdk init
        and our calls where X could crash and cause anaconda to exit, also
        having XLib calls in anaconda would be super gross
      * If we launch the graphical stuff in a separate process that would be
        medium gross
      * If we ask the Gtk to not freaking exit in a library call they probably
        won't
  - Also how much of this stuff needs to go to rhel7-branch


David Shea (17):
  Fix a typo in a comment
  Import gettext in iutil instead of passing the module reference to
    iutil
  Import _ from the i18n module instead of hand-crafting a copy of it
  Remove uses of the deprecated string.split method.
  Remove the exitCode parameter from exitHandler.
  Clear the list of watched PIDs before exiting.
  Handle watched processes exiting.
  Lock program_log_lock closer to where the log is written.
  Add a method startProgram to handle process starting
  Add an option to startProgram to reset signal handlers.
  Add close_fds to the Popen call.
  Simplify iutil.execReadlines.
  Add an option to only capture stdout with execWithCapture
  Close file descriptors while daemonizing auditd
  Move process watching to iutil.
  Move the X startup logic to iutil
  Always use iutil to start processes.

 anaconda                                | 384 ++++++++++----------------------
 pyanaconda/anaconda_log.py              |   4 +-
 pyanaconda/ihelp.py                     |   4 +-
 pyanaconda/isys/auditd.c                |   5 +
 pyanaconda/iutil.py                     | 373 ++++++++++++++++++++++++-------
 pyanaconda/kickstart.py                 |  32 +--
 pyanaconda/rescue.py                    |   4 +-
 pyanaconda/ui/gui/spokes/network.py     |   6 +-
 pyanaconda/ui/tui/spokes/askvnc.py      |   5 +-
 pyanaconda/ui/tui/spokes/shell_spoke.py |   6 +-
 pyanaconda/vnc.py                       |  14 +-
 scripts/instperf                        |   3 +-
 tests/pyanaconda_tests/iutil_test.py    | 227 +++++++++++++++----
 13 files changed, 615 insertions(+), 452 deletions(-)

-- 
1.9.3



More information about the anaconda-patches mailing list