stdout not flushed before os.execvp()

dakman at gmail.com dakman at gmail.com
Tue Oct 17 14:47:38 EDT 2006


If you wanted to make sure stdio was flushed you could always do...

sys.stdout.write("Message\n")
sys.stdout.flush()

Thomas Guettler wrote:
> Hi,
>
> I noticed, that sys.stout does not get flushed before the process is
> replaced. The last print statements (before execvp()) disappear.
>
> It only happens, if the output is redirected to a file (if sys.stdout is
> not line buffered).
>
> """#testexec.py
> import os
> print "Messsage"
> os.execvp("/bin/true", ["/bin/true"])
> """
>
> ===> python tmp/testexec.py
> Messsage
>
> ===> python tmp/testexec.py  > out ; cat out
>
>
> Is this a bug or feature?
>
> My version:
> Python 2.4.2 (#1, May  2 2006, 08:28:01)
> GCC 4.1.0 (SUSE Linux)] on linux2
>
>
> --
> Thomas Güttler, http://www.thomas-guettler.de/ http://www.tbz-pariv.de/
> E-Mail: guettli (*) thomas-guettler + de
> Spam Catcher: niemand.leermann at thomas-guettler.de




More information about the Python-list mailing list