Miscellaneous edits to console-handles.md.

This commit is contained in:
Ryan Prichard 2015-12-15 19:14:10 -06:00
parent 6f2a481b6b
commit 7814da4dd3

View File

@ -1,19 +1,19 @@
Console Handles and Standard Handles
====================================
This document attempts to explain how console handles work and how they
interact with process creation and console attachment and detachment. It is
based on experiments that I ran against various versions of Windows from
Windows XP to Windows 10.
This document attempts to explain how console handles and standard handles
work, and how they interact with process creation and console attachment and
detachment. It is based on experiments that I ran against various versions of
Windows from Windows XP to Windows 10.
The information here is verified by the test suite in the `misc/buffer-tests`
directory. It should be taken with a large grain of salt. I don't have access
directory. It should be taken with a grain of salt. I don't have access
to many operating systems. There may be important things I didn't think to
test. A lot of the behavior is surprising, so it's hard to be sure I have
test. Some of the behavior is surprising, so it's hard to be sure I have
fully identified the behavior.
Feel free to report errors or omissions. An easy thing to do is to run the
accompanying test suite and report errors. The [test suite](#test_suite) is
accompanying test suite and report errors. The [test suite](#test-suite) is
designed to expect bugs on the appropriate Windows releases.
@ -39,6 +39,7 @@ Table of Contents
* [SetActiveConsoleScreenBuffer](#setactiveconsolescreenbuffer)
* [CREATE_NO_WINDOW process creation flag](#create_no_window-process-creation-flag)
* [PROC_THREAD_ATTRIBUTE_HANDLE_LIST](#proc_thread_attribute_handle_list)
* [Bugs](#bugs)
* [Windows XP does not duplicate a pipe's read handle [xppipe]](#windows-xp-does-not-duplicate-a-pipes-read-handle-xppipe)
* [Windows XP duplication inheritability [xpinh]](#windows-xp-duplication-inheritability-xpinh)
* [CreateProcess duplicates `INVALID_HANDLE_VALUE` until Windows 8.1 [dupproc]](#createprocess-duplicates-invalid_handle_value-until-windows-81-dupproc)
@ -46,7 +47,7 @@ Table of Contents
* [Windows Vista BSOD](#windows-vista-bsod)
* [Windows 7 inheritability [win7inh]](#windows-7-inheritability-win7inh)
* [Windows 7 conhost.exe crash with `CONOUT$` [win7_conout_crash]](#windows-7-conhostexe-crash-with-conout-win7_conout_crash)
* [Test suite](#test-suite)
* [Test suite](#test-suite)
* [Footnotes](#footnotes)
@ -126,7 +127,7 @@ Instead, the values are always multiples of four minus one (i.e. 0x3, 0x7,
and perform LPCs to `csrss.exe` and/or `conhost.exe`.
A new console's initial console handles are always inheritable, but
non-inheritable handles can also be created. The inheritability can usually
non-inheritable handles can also be created. The inheritability can
be changed, except on Windows 7 (see [[win7inh]](#win7inh)).
Traditional console handles cannot be duplicated to other processes. If such
@ -395,6 +396,9 @@ are specified:
- *UseStdHandles* is false
- *CreationConsoleMode* is *Inherit*
Bugs
----
### <a name="xppipe">Windows XP does not duplicate a pipe's read handle [xppipe]</a>
On Windows XP, `CreateProcess` fails to duplicate a handle in this situation:
@ -461,10 +465,13 @@ to the last screen buffer, then (2) creating a new screen buffer:
### <a name="win7inh">Windows 7 inheritability [win7inh]</a>
* Calling `DuplicateHandle(bInheritHandle=FALSE)` on an inheritable console
handle produces an inheritable handle. According to documentation and
previous releases, it should be non-inheritable.
handle produces an inheritable handle, but it should be non-inheritable.
Previous and later Windows releases work as expected, as does Windows 7 with
a non-console handle.
* Calling `SetHandleInformation` fails on console handles.
* Calling `SetHandleInformation(dwMask=HANDLE_FLAG_INHERIT)` fails on console
handles, so the inheritability of an existing console handle cannot be
changed.
### <a name="win7_conout_crash">Windows 7 `conhost.exe` crash with `CONOUT$` [win7_conout_crash]</a>
@ -497,7 +504,8 @@ Windows Server 2008 R2 SP1, the server version of the OS.
See `misc/buffer-tests/HandleTests/Win7_Conout_Crash.cc`.
### <a name="test_suite">Test suite</a>
Test suite
----------
To run the `misc/buffer-tests` test suite, follow the instructions for
building winpty. Then, enter the `misc/buffer-tests` directory, run `make`,