diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2008-10-17 16:24:20 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2008-10-17 16:24:20 +0000 |
commit | edf5a5bd1530a09f602227da243b94a88bc8b0b4 (patch) | |
tree | c72d7c1bcab08b8f62bbbf8a7ef2c4ac6f1f38b5 /winsup | |
parent | 5d2b3a0a5a24fb4847e571f5ca4cee7bff9f985c (diff) | |
download | cygnal-edf5a5bd1530a09f602227da243b94a88bc8b0b4.tar.gz cygnal-edf5a5bd1530a09f602227da243b94a88bc8b0b4.tar.bz2 cygnal-edf5a5bd1530a09f602227da243b94a88bc8b0b4.zip |
* dtable.cc (dtable::get_debugger_info): Call SetStdHandle
for the newly opened handle. Explain why.
(dtable::stdio_init): Don't duplicate standard error handle
when stderr has already been created under debugger control.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/dtable.cc | 11 |
2 files changed, 17 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0c3361fcf..444d6b702 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2008-10-17 Corinna Vinschen <corinna@vinschen.de> + + * dtable.cc (dtable::get_debugger_info): Call SetStdHandle + for the newly opened handle. Explain why. + (dtable::stdio_init): Don't duplicate standard error handle + when stderr has already been created under debugger control. + 2008-10-13 Corinna Vinschen <corinna@vinschen.de> * sec_acl.cc (setacl): Align standard owner and group permissions diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index cca215671..d8d7c2ba7 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -128,6 +128,11 @@ dtable::get_debugger_info () release (i); else CloseHandle (h); + /* Copy to Windows' idea of a standard handle, otherwise + we have invalid standard handles when calling Windows + functions (small_printf and strace might suffer, too). */ + SetStdHandle (std_consts[i], i ? fh->get_output_handle () + : fh->get_handle ()); } } } @@ -161,7 +166,11 @@ dtable::stdio_init () /* STD_ERROR_HANDLE has been observed to be the same as STD_OUTPUT_HANDLE. We need separate handles (e.g. using pipes to pass data from child to parent). */ - if (out == err) + /* CV 2008-10-17: Under debugger control, std fd's have been potentially + initialized in dtable::get_debugger_info (). In this case + init_std_file_from_handle is a no-op, so, even if out == err we don't + want to duplicate the handle since it will be unused. */ + if (out == err && (!being_debugged () || !not_open (2))) { /* Since this code is not invoked for forked tasks, we don't have to worry about the close-on-exec flag here. */ |