diff options
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/fhandler/pty.cc | 6 | ||||
-rw-r--r-- | winsup/cygwin/flock.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/child_info.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/fhandler.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/local_includes/tty.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/release/3.6.5 | 3 | ||||
-rw-r--r-- | winsup/cygwin/select.cc | 16 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/tty.cc | 1 |
11 files changed, 29 insertions, 18 deletions
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc index 77a363e..679068e 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -693,8 +693,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on termios_printf ("bytes read %u", n); - if (!buf || ((get_ttyp ()->ti.c_lflag & FLUSHO) - && !get_ttyp ()->mask_flusho)) + if (!buf || (get_ttyp ()->ti.c_lflag & FLUSHO)) continue; /* Discard read data */ memcpy (optr, outbuf, n); @@ -714,8 +713,6 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on } out: - if (buf) - set_mask_flusho (false); termios_printf ("returning %d", rc); return rc; } @@ -2256,7 +2253,6 @@ fhandler_pty_master::write (const void *ptr, size_t len) nlen--; i--; } - process_stop_start (buf[i], get_ttyp ()); } DWORD n; diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index 85800e9..e03caba 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -1162,6 +1162,7 @@ restart: /* Entry point after a restartable signal came in. */ clean = lock; break; + case F_GETLK: case F_OFD_GETLK: error = lf_getlock (lock, node, fl); lock->lf_next = clean; @@ -1721,7 +1722,7 @@ lf_findoverlap (lockf_t *lf, lockf_t *lock, int type, lockf_t ***prev, /* We're "self" only if the semantics and the id matches. OFD and POSIX locks potentially block each other. This is true even for OFD and POSIX locks created by the same process. */ - bool self = (lf->lf_flags == lock->lf_flags) + bool self = ((lf->lf_flags & ~F_WAIT) == (lock->lf_flags & ~F_WAIT)) && (lf->lf_id == lock->lf_id); if (bsd_flock || ((type & SELF) && !self) || ((type & OTHERS) && self)) diff --git a/winsup/cygwin/local_includes/child_info.h b/winsup/cygwin/local_includes/child_info.h index 2da62ff..25d99fa 100644 --- a/winsup/cygwin/local_includes/child_info.h +++ b/winsup/cygwin/local_includes/child_info.h @@ -33,7 +33,7 @@ enum child_status #define EXEC_MAGIC_SIZE sizeof(child_info) /* Change this value if you get a message indicating that it is out-of-sync. */ -#define CURR_CHILD_INFO_MAGIC 0xacbf4682U +#define CURR_CHILD_INFO_MAGIC 0x77f25a01U #include "pinfo.h" struct cchildren @@ -149,6 +149,7 @@ public: void cleanup (); child_info_spawn () {}; + child_info_spawn (child_info_types); child_info_spawn (child_info_types, bool); void record_children (); void reattach_children (); diff --git a/winsup/cygwin/local_includes/fhandler.h b/winsup/cygwin/local_includes/fhandler.h index 4db2964..bdd87eb 100644 --- a/winsup/cygwin/local_includes/fhandler.h +++ b/winsup/cygwin/local_includes/fhandler.h @@ -2625,7 +2625,6 @@ public: } void get_master_thread_param (master_thread_param_t *p); void get_master_fwd_thread_param (master_fwd_thread_param_t *p); - void set_mask_flusho (bool m) { get_ttyp ()->mask_flusho = m; } bool need_send_ctrl_c_event (); }; diff --git a/winsup/cygwin/local_includes/tty.h b/winsup/cygwin/local_includes/tty.h index a418ab1..9485e24 100644 --- a/winsup/cygwin/local_includes/tty.h +++ b/winsup/cygwin/local_includes/tty.h @@ -139,7 +139,6 @@ private: bool master_is_running_as_service; bool req_xfer_input; xfer_dir pty_input_state; - bool mask_flusho; bool discard_input; bool stop_fwd_thread; diff --git a/winsup/cygwin/release/3.6.5 b/winsup/cygwin/release/3.6.5 index f14fbe6..6a37b6a 100644 --- a/winsup/cygwin/release/3.6.5 +++ b/winsup/cygwin/release/3.6.5 @@ -22,3 +22,6 @@ Fixes: - Make process_fd correctly handle pty and console. Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258167.html + +- Fix Ctrl-O (FLUSHO) handling. + Addresses: https://cygwin.com/pipermail/cygwin/2025-August/258717.html diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index a7e82a0..8a94ac0 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -689,6 +689,8 @@ pipe_data_available (int fd, fhandler_base *fh, HANDLE h, int mode) return 0; } +SRWLOCK ptym_peek_lock = SRWLOCK_INIT; + static int peek_pipe (select_record *s, bool from_select) { @@ -730,10 +732,19 @@ peek_pipe (select_record *s, bool from_select) gotone = s->read_ready = true; goto out; } + if (fh->get_major () == DEV_PTYM_MAJOR) + AcquireSRWLockExclusive (&ptym_peek_lock); ssize_t n = pipe_data_available (s->fd, fh, h, PDA_READ); /* On PTY masters, check if input from the echo pipe is available. */ if (n == 0 && fh->get_echo_handle ()) n = pipe_data_available (s->fd, fh, fh->get_echo_handle (), PDA_READ); + if (fh->get_major () == DEV_PTYM_MAJOR) + { + fhandler_pty_master *fhm = (fhandler_pty_master *) fh; + while (n > 0 && (fhm->tc ()->ti.c_lflag & FLUSHO)) + n = fhm->process_slave_output (NULL, n, 0); /* Discard pipe data */ + ReleaseSRWLockExclusive (&ptym_peek_lock); + } if (n == PDA_ERROR) { @@ -759,11 +770,6 @@ peek_pipe (select_record *s, bool from_select) } out: - if (fh->get_major () == DEV_PTYM_MAJOR) - { - fhandler_pty_master *fhm = (fhandler_pty_master *) fh; - fhm->set_mask_flusho (s->read_ready); - } h = fh->get_output_handle (); if (s->write_selected && dev != FH_PIPER) { diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 3618879..30779cf 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -895,7 +895,8 @@ child_info::child_info (unsigned in_cb, child_info_types chtype, msv_count (0), cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC), type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max), flag (0), retry (child_info::retry_count), - rd_proc_pipe (NULL), wr_proc_pipe (NULL), sigmask (_my_tls.sigmask) + rd_proc_pipe (NULL), wr_proc_pipe (NULL), subproc_ready (NULL), + sigmask (_my_tls.sigmask) { fhandler_union_cb = sizeof (fhandler_union); user_h = cygwin_user_h; @@ -946,6 +947,12 @@ child_info_fork::child_info_fork () : { } +child_info_spawn::child_info_spawn (child_info_types chtype) : + child_info (sizeof *this, chtype, false), hExeced (NULL), ev (NULL), + sem (NULL), moreinfo (NULL) +{ +} + child_info_spawn::child_info_spawn (child_info_types chtype, bool need_subproc_ready) : child_info (sizeof *this, chtype, need_subproc_ready) { diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 680f0fe..71add87 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -950,7 +950,7 @@ spawnve (int mode, const char *path, const char *const *argv, if (!envp) envp = empty_env; - child_info_spawn ch_spawn_local (_CH_NADA, false); + child_info_spawn ch_spawn_local (_CH_NADA); switch (_P_MODE (mode)) { case _P_OVERLAY: diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 863f8f2..1b1ff17 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -4535,7 +4535,7 @@ popen (const char *command, const char *in_type) fcntl (stdchild, F_SETFD, stdchild_state | FD_CLOEXEC); /* Start a shell process to run the given command without forking. */ - child_info_spawn ch_spawn_local (_CH_NADA, false); + child_info_spawn ch_spawn_local (_CH_NADA); pid_t pid = ch_spawn_local.worker ("/bin/sh", argv, environ, _P_NOWAIT, __std[0], __std[1]); diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index a4b7167..0c49dc2 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -253,7 +253,6 @@ tty::init () req_xfer_input = false; pty_input_state = to_cyg; last_sig = 0; - mask_flusho = false; discard_input = false; stop_fwd_thread = false; } |