Where have you seen a documentation of the bit patterns of handles?
This will not necessarily work in all implementations (Windows, Wine,
ReactOS).
In Wine's source code and in
http://www.winehq.org/docs/winedev-guide/x3500:
Console handles, on the other hand, are not multiple of four, but have
the two lower bit set (being a multiple of four means having the two
lower bits reset).
I see you pushed this commit, while still using your handle hack. The
cygwin list pointed out this link, which argues against your practice:
http://blogs.msdn.com/oldnewthing/archive/2005/01/21/358109.aspx
I think that's different. "Kernel" handles are NTDLL handles, not
KERNEL32 handles (and consoles are the latter).
I can fix it, but I'm quite swamped these days.
Paolo