-def _ProcessSocatOutput(status_file, level, msg):
- """Interprets socat log output.
-
- """
- if level == SOCAT_LOG_NOTICE:
- if status_file.GetListenPort() is None:
- # TODO: Maybe implement timeout to not listen forever
- m = LISTENING_RE.match(msg)
- if m:
- (_, port) = _VerifyListening(int(m.group("family")), m.group("address"),
- int(m.group("port")))
-
- status_file.SetListenPort(port)
- return True
-
- m = TRANSFER_LOOP_RE.match(msg)
- if m:
- status_file.SetConnected()
- return True
-
- return False
-
-
-def ProcessOutput(line, status_file, logger, socat):
- """Takes care of child process output.
-
- @param status_file: Status file manager
- @param logger: Child output logger
- @type socat: bool
- @param socat: Whether it's a socat output line
- @type line: string
- @param line: Child output line
-
- """
- force_update = False
- forward_line = line
-
- if socat:
- level = None
- parts = line.split(None, 4)
-
- if len(parts) == 5:
- (_, _, _, level, msg) = parts
-
- force_update = _ProcessSocatOutput(status_file, level, msg)
-
- if options.debug or (level and level not in SOCAT_LOG_IGNORE):
- forward_line = "socat: %s %s" % (level, msg)
- else:
- forward_line = None
- else:
- forward_line = "socat: %s" % line
-
- if forward_line:
- logger.info(forward_line)
- status_file.AddRecentOutput(forward_line)
-
- status_file.Update(force_update)
-
-
-def GetBashCommand(cmd):
- """Prepares a command to be run in Bash.
-
- """
- return ["bash", "-o", "errexit", "-o", "pipefail", "-c", cmd]
-
-
-def GetSocatCommand(mode):
- """Returns the socat command.
+def ProcessChildIO(child, socat_stderr_read_fd, dd_stderr_read_fd,
+ dd_pid_read_fd, exp_size_read_fd, status_file, child_logger,
+ signal_notify, signal_handler, mode):
+ """Handles the child processes' output.