Skip to content

Commit 069d204

Browse files
committed
Revert "Revert "Fix OPOST for non-Cygwin pty slaves""
This revert unfortunately reintroduced the "jagged lines" problem. In any case, the culprit this developer tried to fix by reverting the OPOST commit is better worked around in the Git wrapper by forcing `git-bash.exe` to allocate a new console for use by MSys2. This reverts commit aae52e6.
1 parent aae52e6 commit 069d204

File tree

5 files changed

+177
-19
lines changed

5 files changed

+177
-19
lines changed

winsup/cygwin/ChangeLog

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,66 @@
33
* fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close
44
handles not opened via fhandler_pty_slave::fch_open_handles.
55

6+
2015-04-22 Takashi Yano <[email protected]>
7+
8+
* fhandler.h (class fhandler_base): Add virtual function
9+
get_io_handle_cyg() to get handle from which OPOST-processed output is
10+
read on PTY master.
11+
(class fhandler_pty_slave): Add variable output_handle_cyg to store a
12+
handle to which OPOST-processed output is written. Add two functions,
13+
i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding
14+
variable output_handle_cyg. Now, output_handle is used only by native
15+
windows program. The data before OPOST-processing is written to
16+
output_handle and OPOST-processing is applied in the master-side. For a
17+
cygwin process, OPOST-processing is applied in the slave-side, and the
18+
data after OPOST-processing is written to output_handle_cyg.
19+
(class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and
20+
to_master_cyg, to store handles of a pipe through which OPOST-processed
21+
output passes. Add pty_master_fwd_thread and function
22+
pty_master_fwd_thread() for a thread which applies OPOST-processing
23+
and forwards data from io_handle to to_master_cyg. Add function
24+
get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe
25+
between io_handle and to_master are used only by native windows program
26+
for applying OPOST-processing in the master-side. For a cygwin process,
27+
the pipe between io_handle_cyg and to_master_cyg is used for passing
28+
through the data which is applied OPOST-processing in the slave-side.
29+
* fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg.
30+
(fhandler_pty_master::process_slave_output): Read slave output from
31+
io_handle_cyg rather than io_handle.
32+
(fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg.
33+
(fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle
34+
to_master_cyg on PTY master.
35+
(fhandler_pty_slave::close): Close handle output_handle_cyg.
36+
(fhandler_pty_slave::write): Write data to output_handle_cyg rather
37+
than output_handle.
38+
(fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg.
39+
(fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg,
40+
to_master_cyg and master_fwd_thread.
41+
(fhandler_pty_master::cleanup): Clean up to_master_cyg as well.
42+
(fhandler_pty_master::close): Print to_master_cyg as well in debug
43+
message. Terminate master forwarding thread. Close handles
44+
to_master_cyg and io_handle_cyg.
45+
(fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master.
46+
(fhandler_pty_master::pty_master_thread): Add code for duplicating
47+
handle to_master_cyg.
48+
(fhandler_pty_master::pty_master_fwd_thread): New function for a thread
49+
to forward OPOST-processed data from io_handle to to_master_cyg. This
50+
thread applies OPOST-processing to the output of native windows program.
51+
(::pty_master_fwd_thread): Ditto.
52+
(fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST-
53+
processed output. Create new thread to forward data from io_handle to
54+
to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as
55+
well in debug message. Close handles io_handle_cyg and to_master_cyg in
56+
case of error.
57+
(fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to
58+
tty. Copy handle to_master_cyg from arch->to_master_cyg.
59+
(fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg.
60+
* select.cc: Check handle returned by get_io_handle_cyg() rather than
61+
get_handle().
62+
* tty.h (class tty): Add variable _to_master_cyg to store a handle to
63+
which OPOST-processed data is written. Add two functions,
64+
to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg.
65+
666
2015-04-22 Corinna Vinschen <[email protected]>
767

868
* path.cc (basename): Undefine basename before defining function to

winsup/cygwin/fhandler.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ class fhandler_base
412412
that some fd's have two handles. */
413413
virtual HANDLE& get_handle () { return io_handle; }
414414
virtual HANDLE& get_io_handle () { return io_handle; }
415+
virtual HANDLE& get_io_handle_cyg () { return io_handle; }
415416
virtual HANDLE& get_output_handle () { return io_handle; }
416417
virtual HANDLE get_stat_handle () { return pc.handle () ?: io_handle; }
417418
virtual HANDLE get_echo_handle () const { return NULL; }
@@ -1516,6 +1517,7 @@ class fhandler_pty_common: public fhandler_termios
15161517
class fhandler_pty_slave: public fhandler_pty_common
15171518
{
15181519
HANDLE inuse; // used to indicate that a tty is in use
1520+
HANDLE output_handle_cyg;
15191521

15201522
/* Helper functions for fchmod and fchown. */
15211523
bool fch_open_handles (bool chown);
@@ -1526,6 +1528,9 @@ class fhandler_pty_slave: public fhandler_pty_common
15261528
/* Constructor */
15271529
fhandler_pty_slave (int);
15281530

1531+
void set_output_handle_cyg (HANDLE h) { output_handle_cyg = h; }
1532+
HANDLE& get_output_handle_cyg () { return output_handle_cyg; }
1533+
15291534
int open (int flags, mode_t mode = 0);
15301535
void open_setup (int flags);
15311536
ssize_t __stdcall write (const void *ptr, size_t len);
@@ -1576,13 +1581,17 @@ class fhandler_pty_master: public fhandler_pty_common
15761581
HANDLE from_master, to_master;
15771582
HANDLE echo_r, echo_w;
15781583
DWORD dwProcessId; // Owner of master handles
1584+
HANDLE io_handle_cyg, to_master_cyg;
1585+
cygthread *master_fwd_thread; // Master forwarding thread
15791586

15801587
public:
15811588
HANDLE get_echo_handle () const { return echo_r; }
1589+
HANDLE& get_io_handle_cyg () { return io_handle_cyg; }
15821590
/* Constructor */
15831591
fhandler_pty_master (int);
15841592

15851593
DWORD pty_master_thread ();
1594+
DWORD pty_master_fwd_thread ();
15861595
int process_slave_output (char *buf, size_t len, int pktmode_on);
15871596
void doecho (const void *str, DWORD len);
15881597
int accept_input ();

0 commit comments

Comments
 (0)