def redirect_stream(system, target):
if target is None:<EOL><INDENT>target_fd = os.open(os.devnull, os.O_RDWR)<EOL><DEDENT>else:<EOL><INDENT>target_fd = target.fileno()<EOL><DEDENT>try:<EOL><INDENT>os.dup2(target_fd, system.fileno())<EOL><DEDENT>except OSError as err:<EOL><INDENT>raise DaemonError('<STR_LIT>'<EOL>.format(system, target, err))<EOL><DEDENT>
Redirect Unix streams

    If None, redirect Stream to /dev/null, else redirect to target.

    :param system: ether sys.stdin, sys.stdout, or sys.stderr
    :type system: file object

    :param target: File like object, or None
    :type target: None, File Object

    :return: None
    :raise: DaemonError