+ child_io_proc = impexpd.ChildIOProcessor(options.debug, status_file,
+ child_logger, tp_samples,
+ exp_size)
+ try:
+ fdmap = {
+ child.stderr.fileno():
+ (child.stderr, child_io_proc.GetLineSplitter(impexpd.PROG_OTHER)),
+ socat_stderr_read.fileno():
+ (socat_stderr_read, child_io_proc.GetLineSplitter(impexpd.PROG_SOCAT)),
+ dd_pid_read.fileno():
+ (dd_pid_read, child_io_proc.GetLineSplitter(impexpd.PROG_DD_PID)),
+ dd_stderr_read.fileno():
+ (dd_stderr_read, child_io_proc.GetLineSplitter(impexpd.PROG_DD)),
+ exp_size_read.fileno():
+ (exp_size_read, child_io_proc.GetLineSplitter(impexpd.PROG_EXP_SIZE)),
+ signal_notify.fileno(): (signal_notify, None),
+ }
+
+ poller = select.poll()
+ for fd in fdmap:
+ utils.SetNonblockFlag(fd, True)
+ poller.register(fd, select.POLLIN)
+
+ if options.connect_timeout and mode == constants.IEM_IMPORT:
+ listen_timeout = utils.RunningTimeout(options.connect_timeout, True)
+ else:
+ listen_timeout = None
+
+ exit_timeout = None
+ dd_stats_timeout = None
+
+ while True:
+ # Break out of loop if only signal notify FD is left
+ if len(fdmap) == 1 and signal_notify.fileno() in fdmap:
+ break
+
+ timeout = None
+
+ if listen_timeout and not exit_timeout:
+ assert mode == constants.IEM_IMPORT and options.connect_timeout
+ if status_file.GetConnected():
+ listen_timeout = None
+ elif listen_timeout.Remaining() < 0:
+ errmsg = ("Child process didn't establish connection in time"
+ " (%0.0fs), sending SIGTERM" % options.connect_timeout)
+ logging.error(errmsg)
+ status_file.AddRecentOutput(errmsg)
+ status_file.Update(True)
+
+ child.Kill(signal.SIGTERM)
+ exit_timeout = \
+ utils.RunningTimeout(constants.CHILD_LINGER_TIMEOUT, True)
+ # Next block will calculate timeout
+ else:
+ # Not yet connected, check again in a second
+ timeout = 1000
+
+ if exit_timeout:
+ timeout = exit_timeout.Remaining() * 1000
+ if timeout < 0:
+ logging.info("Child process didn't exit in time")