Commit Graph

12300 Commits

Author SHA1 Message Date
Ken Brown b61dc22ada Cygwin: spawnvp, spawnvpe: fail if executable is not in $PATH
Call find_exec with the FE_NNF flag to enforce a NULL return when the
executable isn't found in $PATH.  Convert NULL to "".  This aligns
spawnvp and spawnvpe with execvp and execvpe.
2019-10-18 10:38:52 -04:00
Takashi Yano 43d7f33e2c Cygwin: pty: Change the timing of clear screen. 2019-10-16 15:15:47 -04:00
Takashi Yano 9bedd6807d Cygwin: pty: Avoid detach console in the process running as service. 2019-10-16 15:15:47 -04:00
Ken Brown c561a625af Cygwin: mkdir and rmdir: treat drive names specially
If the directory name has the form 'x:' followed by one or more
slashes or backslashes, and if there's at least one backslash, assume
that the user is referring to 'x:\', the root directory of drive x,
and don't strip the backslash.

Previously all trailing slashes and backslashes were stripped, and the
name was treated as a relative file name containing a literal colon.

Addresses https://cygwin.com/ml/cygwin/2019-08/msg00334.html.
2019-10-07 16:09:41 -04:00
Ken Brown e82a0c959a Cygwin: document recent changes to format_proc_cpuinfo 2019-10-07 16:06:28 -04:00
Brian Inglis 2160c52a49 fhandler_proc.cc(format_proc_cpuinfo): or model extension bits
or model extension bits into model high bits instead of adding
arithmetically like family extension.
2019-10-07 15:50:33 -04:00
Brian Inglis 8cf614a88b fhandler_proc.cc(format_proc_cpuinfo): comment flags not reported
Comment out flags not reported by Linux in cpuinfo, although some
flags may not be used at all by Linux.
2019-10-07 15:50:33 -04:00
Brian Inglis f723e3caae fhandler_proc.cc(format_proc_cpuinfo): add feature flags
Add 99 feature flags including AVX512 extensions, AES, SHA with 20
cpuid calls.
2019-10-07 15:50:33 -04:00
Brian Inglis 08d1ae0543 fhandler_proc.cc(format_proc_cpuinfo): use feature test print macro
Add feature test print macro that makes feature, bit, and flag text
comparison and checking easier.  Handle as common former Intel only
feature flags also supported on AMD.  Change order and some flag names
to agree with current Linux.
2019-10-07 15:50:33 -04:00
Brian Inglis b8ccc22762 fhandler_proc.cc(format_proc_cpuinfo): add microcode
Add microcode from Windows registry Update Revision REG_BINARY.
2019-10-07 15:50:33 -04:00
Brian Inglis 9682c25bb3 fhandler_proc.cc(format_proc_cpuinfo): add bogomips
Add bogomips which has been cpu MHz*2 since Pentium MMX.
2019-10-07 15:50:33 -04:00
Brian Inglis 70e834ea7c fhandler_proc.cc(format_proc_cpuinfo): round cpu MHz
Round cpu MHz to correct Windows and match Linux cpuinfo.
2019-10-07 15:50:32 -04:00
Brian Inglis 7a0496f78f fhandler_proc.cc(format_proc_cpuinfo): fix AMD physical cores count
Fix AMD physical cores count documented as core_info low byte + 1.
2019-10-07 15:50:32 -04:00
Brian Inglis 74aa6e3cdb fhandler_proc.cc(format_proc_cpuinfo): fix cpuid level count
Fix cpuid level count as number of non-zero leafs excluding sub-leafs.
2019-10-07 15:50:32 -04:00
Brian Inglis acc8849f84 fhandler_proc.cc(format_proc_cpuinfo): fix cache size
Fix cache size return code handling and make AMD/Intel code common.
2019-10-07 15:50:32 -04:00
Takashi Yano df5c79f30c Cygwin: Fix signal handling issue introduced by PTY related change.
- After commit 4186409101, there is a
  regression in signal handling reported in
  https://www.cygwin.com/ml/cygwin/2019-10/msg00010.html. This patch
  fixes the issue.
2019-10-03 09:28:10 -04:00
Ken Brown 6061f9c76f Document the last bug fix 2019-09-27 13:36:45 -04:00
Ken Brown 283cb372e4 Cygwin: normalize_win32_path: improve error checking
If the source path starts with the Win32 long path prefix '\\?\' or
the NT object directory prefix '\??\', require the prefix to be
followed by 'UNC\' or '<drive letter>:\'.  Otherwise return EINVAL.

This fixes the assertion failure in symlink_info::check that was
reported here:

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

That assertion failure was caused by normalize_win32_path returning a
path with no backslashes when the source path was '\\?\DRIVE'.
2019-09-26 08:52:13 -04:00
Takashi Yano e1a0775dc0 Cygwin: pty: Fix PTY so that cygwin setup shows help with -h option.
- After commit 169d65a577, cygwin
  setup fails to show help message when -h option is specified, as
  reported in https://cygwin.com/ml/cygwin/2019-09/msg00248.html.
  This patch fixes the problem.
2019-09-26 08:42:52 -04:00
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