[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [PATCH] Do not use communicate() when we redirect to file desc, it changes line buffering to block buffering which makes interactive scripts in kickstart impossible to use (#506664)



> diff --git a/iutil.py b/iutil.py
> index ba1d0b4..1e90025 100644
> --- a/iutil.py
> +++ b/iutil.py
> @@ -87,23 +87,13 @@ def execWithRedirect(command, argv, stdin = None, stdout = None,
>  
>      try:
>          proc = subprocess.Popen([command] + argv, stdin=stdin,
> -                                stdout=subprocess.PIPE,
> -                                stderr=subprocess.PIPE,
> +                                stdout=stdout,
> +                                stderr=stderr,
>                                  preexec_fn=chroot, cwd=root,
>                                  env=env)
> +        proc.wait()
> +        ret = proc.returncode
>  
> -        while True:
> -            (outStr, errStr) = proc.communicate()
> -            if outStr:
> -                os.write(stdout, outStr)
> -                runningLog.write(outStr)
> -            if errStr:
> -                os.write(stderr, errStr)
> -                runningLog.write(errStr)
> -
> -            if proc.returncode is not None:
> -                ret = proc.returncode
> -                break
>      except OSError as e:
>          errstr = "Error running %s: %s" % (command, e.strerror)
>          log.error(errstr)

This means that anything run through execWithRedirect will not get
written to /tmp/program.log, though.

- Chris


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]