@@ -171,9 +171,9 @@ This module defines one class called :class:`Popen`:
171171 :attr: `stdout `, :attr: `stdin ` and :attr: `stderr ` are not updated by the
172172 :meth: `communicate ` method.
173173
174- The *startupinfo * and * creationflags *, if given, will be passed to the
175- underlying CreateProcess() function. They can specify things such as appearance
176- of the main window and priority for the new process. (Windows only)
174+ If given, *startupinfo * will be a :class: ` STARTUPINFO ` object, which is
175+ passed to the underlying `` CreateProcess `` function.
176+ * creationflags *, if given, can be :data: ` CREATE_NEW_CONSOLE `. (Windows only)
177177
178178
179179.. data :: PIPE
@@ -428,6 +428,101 @@ The following attributes are also available:
428428 ``N `` (Unix only).
429429
430430
431+ Windows Popen Helpers
432+ ---------------------
433+
434+ The :class: `STARTUPINFO ` class and following constants are only available
435+ on Windows.
436+
437+ .. class :: STARTUPINFO()
438+
439+ Partial support of the Windows
440+ `STARTUPINFO <http://msdn.microsoft.com/en-us/library/ms686331(v=vs.85).aspx >`__
441+ structure is used for :class: `Popen ` creation.
442+
443+ .. attribute :: dwFlags
444+
445+ A bit field that determines whether certain :class: `STARTUPINFO ` members
446+ are used when the process creates a window. ::
447+
448+ si = subprocess.STARTUPINFO()
449+ si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW
450+
451+ .. attribute :: hStdInput
452+
453+ If :attr: `dwFlags ` specifies :data: `STARTF_USESTDHANDLES `, this member is
454+ the standard input handle for the process. If :data: `STARTF_USESTDHANDLES `
455+ is not specified, the default for standard input is the keyboard buffer.
456+
457+ .. attribute :: hStdOutput
458+
459+ If :attr: `dwFlags ` specifies :data: `STARTF_USESTDHANDLES `, this member is
460+ the standard output handle for the process. Otherwise, this member is
461+ ignored and the default for standard output is the console window's
462+ buffer.
463+
464+ .. attribute :: hStdError
465+
466+ If :attr: `dwFlags ` specifies :data: `STARTF_USESTDHANDLES `, this member is
467+ the standard error handle for the process. Otherwise, this member is
468+ ignored and the default for standard error is the console window's buffer.
469+
470+ .. attribute :: wShowWindow
471+
472+ If :attr: `dwFlags ` specifies :data: `STARTF_USESHOWWINDOW `, this member
473+ can be any of the values that can be specified in the ``nCmdShow ``
474+ parameter for the
475+ `ShowWindow <http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx >`__
476+ function, except for ``SW_SHOWDEFAULT ``. Otherwise, this member is
477+ ignored.
478+
479+ :data: `SW_HIDE ` is provided for this attribute. It is used when
480+ :class: `Popen ` is called with ``shell=True ``.
481+
482+
483+ Constants
484+ ^^^^^^^^^
485+
486+ The :mod: `subprocess ` module exposes the following constants.
487+
488+ .. data :: STD_INPUT_HANDLE
489+
490+ The standard input device. Initially, this is the console input buffer,
491+ ``CONIN$ ``.
492+
493+ .. data :: STD_OUTPUT_HANDLE
494+
495+ The standard output device. Initially, this is the active console screen
496+ buffer, ``CONOUT$ ``.
497+
498+ .. data :: STD_ERROR_HANDLE
499+
500+ The standard error device. Initially, this is the active console screen
501+ buffer, ``CONOUT$ ``.
502+
503+ .. data :: SW_HIDE
504+
505+ Hides the window. Another window will be activated.
506+
507+ .. data :: STARTF_USESTDHANDLES
508+
509+ Specifies that the :attr: `STARTUPINFO.hStdInput `,
510+ :attr: `STARTUPINFO.hStdOutput `, and :attr: `STARTUPINFO.hStdError ` members
511+ contain additional information.
512+
513+ .. data :: STARTF_USESHOWWINDOW
514+
515+ Specifies that the :attr: `STARTUPINFO.wShowWindow ` member contains
516+ additional information.
517+
518+ .. data :: CREATE_NEW_CONSOLE
519+
520+ The new process has a new console, instead of inheriting its parent's
521+ console (the default).
522+
523+ This flag is always set when :class: `Popen ` is created with ``shell=True ``.
524+
525+
431526.. _subprocess-replacements :
432527
433528Replacing Older Functions with the subprocess Module
0 commit comments