Commit Graph

12281 Commits

Author SHA1 Message Date
Ken Brown a9724c3904 Document the last change 2019-09-24 20:04:28 -04:00
Ken Brown d1b5feef82 Cygwin: rmdir: fail if last component is a symlink, as on Linux
If the last component of the directory name is a symlink followed by a
slash, rmdir now fails, following Linux but not POSIX, even if the
symlink resolves to an existing empty directory.

mkdir was similarly changed in 2009 in commit
52dba6a5c4.  Modify a comment to clarify
the purpose of that commit.

Addresses https://cygwin.com/ml/cygwin/2019-09/msg00221.html.
2019-09-24 20:03:30 -04:00
Ken Brown 9f24260ee9 Cygwin: remove old cruft from path_conv::check
Prior to commit b0717aae, path_conv::check had the following code:

      if (strncmp (path, "\\\\.\\", 4))
        {
          /* Windows ignores trailing dots and spaces in the last path
             component, and ignores exactly one trailing dot in inner
             path components. */
          char *tail = NULL;
          [...]
          if (!tail || tail == path)
            /* nothing */;
          else if (tail[-1] != '\\')
            {
              *tail = '\0';
          [...]
        }

Commit b0717aae0 intended to disable this code, but it inadvertently
disabled only part of it.  In particular, the declaration of the local
tail variable was in the disabled code, but the following remained:

          if (!tail || tail == path)
            /* nothing */;
          else if (tail[-1] != '\\')
            {
              *tail = '\0';
          [...]
        }

[A later commit removed the disabled code.]

The tail variable here points into a string different from path,
causing that string to be truncated under some circumstances.  See

  https://cygwin.com/ml/cygwin/2019-09/msg00001.html

for more details.

This commit fixes the problem by removing the leftover code
that was intended to be removed in b0717aae.
2019-09-21 13:09:09 -04:00
Takashi Yano 4186409101 Cygwin: Fix incorrect TTY for non-cygwin process.
- After commit d4045fdbef, the TTY
  displayed by ps command is incorrect if the process is non-cygwin
  process. This patch fixes this issue.
2019-09-20 17:48:37 -04:00
Takashi Yano aa529d00ea Cygwin: console: Make console input work in GDB and strace.
- After commit 2232498c71, console
  input cause error in GDB or strace. This patch fixes this issue.
2019-09-20 17:48:37 -04:00
Takashi Yano 81c55654e6 Cygwin: pty: Add missing guard when PTY is in the legacy mode. 2019-09-20 16:18:47 -04:00
Takashi Yano b757a21d85 Cygwin: pty: Add charset conversion for console apps in legacy PTY. 2019-09-20 16:18:47 -04:00
Takashi Yano 24554ab923 Cygwin: pty: Unify the charset conversion codes into a function. 2019-09-20 16:18:47 -04:00
Takashi Yano ac5357b9fe Cygwin: pty: Make GDB work again on pty. 2019-09-20 16:18:47 -04:00
Takashi Yano 831b1569dc Cygwin: pty: Avoid potential segfault in PTY code when ppid = 1. 2019-09-20 16:18:47 -04:00
Takashi Yano 1a44ad03e0 Cygwin: console: Revive Win7 compatibility.
- The commit fca4cda7a4 broke Win7
  compatibility. This patch fixes the issue.
2019-09-19 22:17:54 -04:00
Ken Brown bbc625da81 Cygwin: document last change 2019-09-15 13:40:12 -04:00
Achim Gratz d5f84126e5 winsup/cygwin/times.cc (times): follow Linux and allow for a NULL buf argument
Adresses the problem reported here:

  https://cygwin.com/ml/cygwin/2019-09/msg00141.html
2019-09-15 13:12:03 -04:00
Takashi Yano 70cd49e204 Cygwin: pty: Use autoload feature for pseudo console system calls.
- The autoload feature is used rather than GetModuleHandle(),
  GetProcAddress() for CreatePseudoConsole(), ResizePseudoConsole()
  and ClosePseudoConsole().
2019-09-15 11:12:45 -04:00
Takashi Yano fac5a01aec Cygwin: pty: Correct typos that do not fit the coding style. 2019-09-15 11:12:20 -04:00
Takashi Yano 244f03627d Cygwin: pty: Change the timing of clearing screen.
- The code which clears screen is moved from reset_switch_to_pcon()
  to fixup_after_exec() because it seems not too early even at this
  timing.
2019-09-15 11:09:06 -04:00
Takashi Yano d83c45b46c Cygwin: pty: Use system NLS function instead of PTY's own one.
- Since calling system __loadlocale() caused execution error,
  PTY used its own NLS function. The cause of the error has been
  found, the corresponding code has been rewritten using system
  function.
2019-09-15 11:09:06 -04:00
Takashi Yano 6983433f8e Cygwin: pty: Fix bad file descriptor error in some environment.
- The bad file descriptor problem reported in:
  https://cygwin.com/ml/cygwin-patches/2019-q3/msg00104.html
  was recurring. Fixed again.
2019-09-15 11:09:06 -04:00
Mark Geisert a083a4f266 Cygwin: fix CPU_SET macro visibility
The CPU_SET macros defined in Cygwin's include/sys/cpuset.h must not
be visible in an application's namespace unless _GNU_SOURCE has been
#defined.  Internally this means wrapping them in #if __GNU_VISIBLE.
2019-09-14 11:31:17 -04:00
Takashi Yano fca4cda7a4 Cygwin: console: Fix read() in non-canonical mode.
- In non-canonical mode, cygwin console returned only one character
  even if several keys are typed before read() called. This patch
  fixes this behaviour.
2019-09-14 09:19:04 -04:00
Takashi Yano 3355a6d4b9 Cygwin: pty: Switch input and output pipes individually.
- Previously, input and output pipes were switched together between
  the traditional pty and the pseudo console. However, for example,
  if stdin is redirected to another device, it is better to leave
  input pipe traditional pty side even for non-cygwin program. This
  patch realizes such behaviour.
2019-09-14 09:19:04 -04:00
Takashi Yano cac5f8781a Cygwin: pty: Prevent the helper process from exiting by Ctrl-C. 2019-09-14 09:17:27 -04:00
Takashi Yano bd31b7c5d5 Cygwin: pty: Fix screen alternation while pseudo console switching.
- If screen alternated while pseudo console switching, it sometimes
  failed. This might happen when the output of the non-cygwin program
  is piped to less. This patch fixes this issue.
2019-09-14 09:17:27 -04:00
Takashi Yano b088f50426 Cygwin: pty: Fix the behaviour of Ctrl-C in the pseudo console mode.
- When the I/O pipe is switched to the pseudo console side, the
  behaviour of Ctrl-C was unstable. This rarely happens, however,
  for example, shell sometimes crashes by Ctrl-C in that situation.
  Furthermore, Ctrl-C was ignored if output of non-cygwin program
  is redirected to pipe. This patch fixes these issues.
2019-09-14 08:58:35 -04:00
Takashi Yano f39a694c46 Cygwin: pty: Make SetConsoleCursorPosition() to be hooked.
- Win32 API SetConsoleCursorPosition() injects ANSI escape sequence
  to pseudo console. Therefore, it should be added to the API list
  to be hooked.
2019-09-06 12:31:17 -04:00
Takashi Yano 46d3953d64 Cygwin: pty: Make sure to show system error messages
- Forcibly attach to pseudo console in advance so that the error
  messages by system_printf() are displayed to screen reliably.
  This is needed when stdout is redirected to another pty. In this
  case, process has two ptys opened. However, process can attach
  to only one console. So it is necessary to change console attached.
2019-09-05 11:42:26 -04:00
Takashi Yano b7e4294200 Cygwin: pty: Fix potential state mismatch regarding pseudo console.
- PTY with pseudo console support sitll has problem which potentially
  cause state mismatch between state variable and real console state.
  This patch fixes this issue.
2019-09-05 13:59:37 +02:00
Takashi Yano 915fcd0ae8 Cygwin: pty: Fix select() with pseudo console support.
- select() did not work correctly when both read and except are
  polled simultaneously for the same fd and the r/w pipe is switched
  to pseudo console side. This patch fixes this isseu.
2019-09-05 13:59:37 +02:00
Takashi Yano 433c6b8e0a Cygwin: pty: Disable clear screen on new pty if TERM=dumb or emacs*.
- Pseudo console support introduced by commit
  169d65a577 shows garbage ^[[H^[[J in
  some of emacs screens. These screens do not handle ANSI escape
  sequences. Therefore, clear screen is disabled on these screens.
2019-09-05 13:59:37 +02:00
Takashi Yano d4045fdbef Cygwin: pty: Add a workaround for ^C handling.
- Pseudo console support introduced by commit
  169d65a577 sometimes cause random
  crash or freeze by pressing ^C while cygwin and non-cygwin
  processes are executed simultaneously in the same pty. This
  patch is a workaround for this issue.
2019-09-04 16:01:07 +02:00
Takashi Yano 83b2d576c8 Cygwin: pty: Limit API hook to the program linked with the APIs.
- API hook used for pseudo console support causes slow down.
  This patch limits API hook to only program which is linked
  with the corresponding APIs. Normal cygwin program is not
  linked with such APIs (such as WriteFile, etc...) directly,
  therefore, no slow down occurs. However, console access by
  cygwin.dll itself cannot switch the r/w pipe to pseudo console
  side. Therefore, the code to switch it forcely to pseudo
  console side is added to smallprint.cc and strace.cc.
2019-09-04 15:59:38 +02:00
Takashi Yano 583102e7c9 Cygwin: pty: Fix state management for pseudo console support.
- Pseudo console support introduced by commit
  169d65a577 has some bugs which
  cause mismatch between state variables and real pseudo console
  state regarding console attaching and r/w pipe switching. This
  patch fixes this issue by redesigning the state management.
2019-09-04 12:05:15 +02:00
Takashi Yano ffbb9b4971 Cygwin: pty: Move function hook_api() into hookapi.cc.
- PTY uses Win32 API hook for pseudo console suppot. The function
  hook_api() is used for this purpose and defined in fhandler_tty.cc
  previously. This patch moves it into hookapi.cc.
2019-09-04 11:59:46 +02:00
Takashi Yano bddb018e10 Cygwin: pty: Speed up a little hooked Win32 API for pseudo console.
- Some Win32 APIs are hooked in pty code for pseudo console support.
  This causes slow down. This patch improves speed a little.
2019-09-04 11:59:46 +02:00
Takashi Yano 9adb260181 Cygwin: pty: Code cleanup
- Cleanup the code which is commented out by #if 0 regarding pseudo
  console.
- Remove #if 1 for experimental code which seems to be stable.
2019-09-04 11:59:46 +02:00
Corinna Vinschen 7630c77026 Cygwin: sys/wait.h: Add _wait prototype to avoid compiler warning
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-09-03 17:00:43 +02:00
Corinna Vinschen 483fb49ea0 Cygwin: add W10 pseudo console support to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-29 13:56:43 +02:00
Takashi Yano 169d65a577 Cygwin: pty: add pseudo console support.
- Support pseudo console in PTY. Pseudo console is a new feature
  in Windows 10 1809, which provides console APIs on virtual
  terminal. With this patch, native console applications can work
  in PTYs such as mintty, ssh, gnu screen or tmux.
2019-08-29 13:47:40 +02:00
Ken Brown 398476acd2 Cygwin: get_posix_access: avoid negative subscript
Don't refer to lacl[pos] unless we know that pos >= 0.
2019-08-26 13:38:31 -04:00
Martin Storsjö f7f296b46f Cygwin: math: Properly propagate input NANs in a few functions
While the C99 standard doesn't explicitly require this, the standard
says it is recommended (F.9.13).

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-08-20 18:15:16 +02:00
Martin Storsjö 8dee6fe6a5 Cygwin: math: Fix cosh(-INFINITY) to return +INFINITY
Signed-off-by: Martin Storsjö <martin@martin.st>
2019-08-20 18:15:16 +02:00
Martin Storsjö f4e7849fa9 Cygwin: math: Fix the return value for tgammal for zero and negative integers
For zero, it should return HUGE_VAL (INFINITY), for negative integers,
it should return NAN.

Signed-off-by: Martin Storsjö <martin@martin.st>
2019-08-20 18:15:16 +02:00
Corinna Vinschen 7097b05eda Cygwin: select: revamp non-polling code for signalfd
Rather than waiting for signalfd_select_wait in a thread, which is racy,
create a global event "my_pendingsigs_evt" which is set and reset by
wait_sig depending only on the fact if blocked signals are pending or not.

This in turn allows to WFMO on this event in select as soon as signalfds
are present in the read descriptor set.  Select's peek and verify
will then check if one of the present signalfds is affected.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-18 14:02:01 +02:00
Corinna Vinschen b7399d5e6f Revert "Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario"
This reverts commit 92115a83a4.

This was utterly wrong.
2019-08-17 10:12:16 +02:00
Mark Geisert e3ca53d9db Cygwin: ldd: Try harder to get dll names
Borrow a trick from strace to lessen occurrences of "??? => ???" in ldd
output.  Specifically, if the module name isn't found in the usual place
in the mapped image, use the file handle we have to look up the name.
2019-08-15 09:56:11 +02:00
Takashi Yano 3a929f27f8 Cygwin: console: Fix the condition to interrupt select() by SIGWINCH
- Add code so that select() is not interrupted by SIGWINCH if it is
  ignored (SIG_IGN or SIG_DFL).
2019-08-15 09:53:33 +02:00
Takashi Yano e6910dfff6 Cygwin: console: Fix workaround for horizontal tab position
- The workaround commit 33a21904a7
  does not work as expected if window size is changed while screen
  is alternated. Fixed.
2019-08-15 09:53:33 +02:00
Corinna Vinschen 92115a83a4 Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario
On sigwaitinfo or reading from a signalfd, signal processing sets up
signal handling via sigdelayed even if the handler address is NULL.
This doesn't have any impact on sigwaitinfo scenarios (or at least, I
wasn't able to come up with a reproducer) but it breaks signalfd
scenarios, where eventually a call to call_signal_handler from
sigdelayed will try to call the NULL function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-13 12:21:05 +02:00
Corinna Vinschen 3b4685bf97 Cygwin: ps: fix a compiler warning
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-12 17:30:20 +02:00
Takashi Yano d178de278a Cygwin: console: Fix cursor position restore after screen alternation.
- If screen is alternated on console, cursor position is not restored
  correctly in the case of xterm compatible mode is enabled. For example,
  the shell prompt is shown at incorrect position after using vim.
  This patch fixes this problem.
2019-08-12 17:08:48 +02:00