* dtable.cc (dtable::init_std_file_from_handle): Add workaround for

Windows 7 64 bit issue.  Add lengthy comment to explain what happens.
	* wincap.h (wincaps::has_console_handle_problem): New element.
	* wincap.cc: Implement above element throughout.
	(wincap_7): New wincaps structure for NT 6.1 kernels.
	(wincapc::init): Set has_console_handle_problem to false for 32 bit
	systems.

	Fix broken older ChangeLog entry.
This commit is contained in:
Corinna Vinschen 2009-05-09 15:56:37 +00:00
parent a22af4a956
commit 9b98d6a8fb
4 changed files with 96 additions and 3 deletions

View File

@ -1,3 +1,13 @@
2009-05-09 Corinna Vinschen <corinna@vinschen.de>
* dtable.cc (dtable::init_std_file_from_handle): Add workaround for
Windows 7 64 bit issue. Add lengthy comment to explain what happens.
* wincap.h (wincaps::has_console_handle_problem): New element.
* wincap.cc: Implement above element throughout.
(wincap_7): New wincaps structure for NT 6.1 kernels.
(wincapc::init): Set has_console_handle_problem to false for 32 bit
systems.
2009-05-09 Corinna Vinschen <corinna@vinschen.de>
* sec_auth.cc (str2uni_cat): Move from here...
@ -880,7 +890,7 @@
* path.cc (symlink_info::check): Add workaround for UDF bug in
terms of casesensitivity on certain OSes.
* wincap.h (wincaps::has_broken_udf): New element.
(wincaps::has_broken_udf): New element
* wincap.cc: Implement above element throughout.
2009-01-27 Christopher Faylor <me+cygwin@cgf.cx>

View File

@ -358,7 +358,32 @@ dtable::init_std_file_from_handle (int fd, HANDLE handle)
else
access |= GENERIC_WRITE; /* Should be rdwr for stderr but not sure that's
possible for some versions of handles */
fh->init (handle, access, bin);
/* FIXME: Workaround Windows 7 64 bit issue. If the parent process of
the process tree closes the original handles to the console window,
strange problems occur when starting child processes later on if
stdio redirection is used. How to reproduce:
shell script foo:
exec 2>foo.log
FOO=$( uname -n | cat )
echo $FOO
start from cmd with `bash foo'. The result is that the cat process
will be started but dies before Cygwin strace output can be generated
and $FOO stays empty. The strace output shows that bash tries
multiple times to start cat, but none of the invocations of cat will
ever show up in the strace output.
Remove the `exec 2>' or remove the cat call and the script will work.
Start bash interactively, then start the script manually, and the
script will work.
This needs further investigation but the workaround not to close
the handles will have a marginal hit of three extra handles per
process at most. */
fh->init (dev == FH_CONSOLE && wincap.has_console_handle_problem ()
? INVALID_HANDLE_VALUE : handle, access, bin);
set_std_handle (fd);
paranoid_printf ("fd %d, handle %p", fd, handle);
}

View File

@ -54,6 +54,7 @@ wincaps wincap_unknown __attribute__((section (".cygwin_dll_common"), shared)) =
has_recvmsg:false,
has_sendmsg:false,
has_broken_udf:false,
has_console_handle_problem:false,
};
wincaps wincap_nt4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -90,6 +91,7 @@ wincaps wincap_nt4 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:false,
has_sendmsg:false,
has_broken_udf:false,
has_console_handle_problem:false,
};
wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -126,6 +128,7 @@ wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
has_recvmsg:false,
has_sendmsg:false,
has_broken_udf:false,
has_console_handle_problem:false,
};
wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -162,6 +165,7 @@ wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:false,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -198,6 +202,7 @@ wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) =
has_recvmsg:false,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -234,6 +239,7 @@ wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:true,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -270,6 +276,7 @@ wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:true,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -306,6 +313,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:true,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -342,6 +350,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:true,
has_sendmsg:false,
has_broken_udf:true,
has_console_handle_problem:false,
};
wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
@ -378,6 +387,44 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = {
has_recvmsg:true,
has_sendmsg:true,
has_broken_udf:false,
has_console_handle_problem:false,
};
wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = {
chunksize:0,
heapslop:0x4,
max_sys_priv:SE_CREATE_SYMBOLIC_LINK_PRIVILEGE,
is_server:false,
has_dacl_protect:true,
has_ip_helper_lib:true,
has_broken_if_oper_status:false,
has_physical_mem_access:false,
has_process_io_counters:true,
has_terminal_services:true,
has_create_global_privilege:true,
has_ioctl_storage_get_media_types_ex:true,
has_extended_priority_class:true,
has_guid_volumes:true,
has_disk_ex_ioctls:true,
has_disabled_user_tos_setting:true,
has_fileid_dirinfo:true,
has_exclusiveaddruse:true,
has_enhanced_socket_security:true,
has_buggy_restart_scan:false,
has_mandatory_integrity_control:true,
needs_logon_sid_in_sid_list:false,
needs_count_in_si_lpres2:true,
has_recycle_dot_bin:true,
has_gaa_prefixes:true,
has_gaa_on_link_prefix:true,
supports_all_posix_ai_flags:true,
has_restricted_stack_args:false,
has_transactions:true,
ts_has_dep_problem:false,
has_recvmsg:true,
has_sendmsg:true,
has_broken_udf:false,
has_console_handle_problem:true,
};
wincapc wincap __attribute__((section (".cygwin_dll_common"), shared));
@ -441,7 +488,15 @@ wincapc::init ()
}
break;
case 6:
caps = &wincap_vista;
switch (version.dwMinorVersion)
{
case 0:
caps = &wincap_vista;
break;
default:
caps = &wincap_7;
break;
}
break;
default:
caps = &wincap_unknown;
@ -474,6 +529,7 @@ wincapc::init ()
{
((wincaps *)caps)->needs_count_in_si_lpres2 = false;
((wincaps *)caps)->has_restricted_stack_args = false;
((wincaps *)caps)->has_console_handle_problem = false;
}
__small_sprintf (osnam, "NT-%d.%d", version.dwMajorVersion,

View File

@ -46,6 +46,7 @@ struct wincaps
unsigned has_recvmsg : 1;
unsigned has_sendmsg : 1;
unsigned has_broken_udf : 1;
unsigned has_console_handle_problem : 1;
};
class wincapc
@ -98,6 +99,7 @@ public:
bool IMPLEMENT (has_recvmsg)
bool IMPLEMENT (has_sendmsg)
bool IMPLEMENT (has_broken_udf)
bool IMPLEMENT (has_console_handle_problem)
#undef IMPLEMENT
};