Commit 81184713 authored by Anael Beutot's avatar Anael Beutot
Browse files

Close fds in child for safe migration and reset signal map

parent e22cd3f8
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ from cloudcontrol.node.exc import (
from cloudcontrol.node.hypervisor.jobs import (
    ImportVolume, ExportVolume, TCPTunnel, DRBD,
)
from cloudcontrol.node.utils import close_fds, set_signal_map


logger = logging.getLogger(__name__)
@@ -360,7 +361,17 @@ class Handler(HostHandler):
            # child
            sys.stderr.write('Hello from child !\n')
            sys.stderr.write('Debug is %s\n' % self.main.config.debug)
            # FIXME we should close all unused fds
            try:
                close_fds(debug=self.main.config.debug)
                set_signal_map({
                    signal.SIGTERM: lambda *args: os._exit(1),
                    signal.SIGUSR1: signal.SIG_IGN,
                    signal.SIGINT: signal.SIG_IGN,
                    # FIXME need more signal ?
                })
            except:
                sys.stderr.write('Error while performing post fork work\n')
                traceback.print_exc(file=sys.stderr)
            # create a new libvirt connection dedicated to migration
            sys.stderr.write('Open new connection to libvirt\n')
            try: