Commit Graph

8709 Commits

Author SHA1 Message Date
Takashi Yano 27202a1b14 Cygwin: pty: Fix ESC[?3h and ESC[?3l handling again.
- Even with commit fe512b2b12, pty
  still has a problem in ESC[?3h and ESC[?3l handling if invalid
  sequence such as ESC[?$ is sent. This patch fixes the issue.
2019-12-19 12:28:20 +01:00
Takashi Yano fe512b2b12 Cygwin: pty: Fix a bug regarding ESC[?3h and ESC[?3l handling.
- Midnight commander (mc) does not work after the commit
  1626569222 as reported in
  https://www.cygwin.com/ml/cygwin/2019-12/msg00173.html.
  This patch fixes the issue.
2019-12-18 20:20:13 +01:00
Corinna Vinschen 7fc78f07ed Cygwin: Bump DLL version to 3.1.2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-18 10:48:10 +01:00
Corinna Vinschen 5317e3f4ec Cygwin: add 3.1.1 release text belatedly
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-18 10:47:43 +01:00
Corinna Vinschen 26cc7769b4 Cygwin: autoload: Add missing GetProcessGroupAffinity/GetThreadGroupAffinity
Both functions were introduce with Windows 7 only, so we need to
autoload them for the sake of Vista/2008.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-17 16:44:54 +01:00
Corinna Vinschen d3574fc148 Cygwin: Bump DLL version to 3.1.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-16 21:09:50 +01:00
Corinna Vinschen f69b2421bb Cygwin: add strtold fix to release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-16 16:39:17 +01:00
Corinna Vinschen 29ba52da95 Cygwin: ilogbl: Make sure to return FP_ILGB0 on zero input
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-12-16 10:50:17 +01:00
Ken Brown 69772c4332 Cygwin: document the last bugfix 2019-12-10 08:45:17 -05:00
Ken Brown 48fbe173f4 Cygwin: symlink_info::check: avoid assertion failure
On certain error conditions there is a code snippet that checks
whether the last component of the path has a trailing dot or space or
a leading space.  Skip this check if the last component is empty,
i.e., if the path ends with a backslash.  This avoids an assertion
failure if the trailing backslash is the only backslash in the path,
as is the case for a DOS drive 'X:\'.

Addresses: https://cygwin.com/ml/cygwin/2019-12/msg00016.html
2019-12-09 07:43:44 -05:00
Anton Lavrentiev via cygwin-patches 8574f8a1e4 Cygwin: /proc/[PID]/stat to pull process priority correctly
Fix to prior commit 5fa9a0e7 to address https://cygwin.com/ml/cygwin/2019-08/msg00082.html
2019-12-02 09:57:04 +01:00
Takashi Yano edb1be4cce Cygwin: pty: Convert CamelCase names to snake_case names. 2019-11-18 11:12:08 +01:00
Takashi Yano 1626569222 Cygwin: pty: Trigger redraw screen if ESC[?3h or ESC[?3l is sent.
- Pseudo console clears console screen buffer if ESC[?3h or ESC[?3l
  is sent. However, xterm/vt100 does not clear screen. This cause
  mismatch between real screen and console screen buffer. Therefore,
  this patch triggers redraw screen in that situation so that the
  synchronization is done on the next execution of native app.
  This solves the problem reported in:
  https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00116.html
2019-11-15 13:07:40 +01:00
Takashi Yano 8f8522c82a Cygwin: console: Revise the code checking if the console is legacy.
- Accessing shared_console_info before initializing causes access
  violation in checking if the console is legacy mode. This patch
  fixes this issue. This solves the problem reported in:
  https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00099.html
2019-11-13 10:27:46 +01:00
Takashi Yano 7ef4290a98 Cygwin: pty: Use redraw screen instead of clear screen.
- Previously, pty cleared screen at startup for synchronization
  between the real screen and console screen buffer for pseudo
  console. With this patch, instead of clearing screen, the screen
  is redrawn when the first native program is executed after pty
  is created. In other words, synchronization is deferred until
  the native app is executed. Moreover, this realizes excluding
  $TERM dependent code.
2019-11-13 09:56:41 +01:00
Mark Geisert 04d85dea57 Cygwin: Doc change to note stackdump limit patch 2019-11-08 10:23:08 +01:00
Mark Geisert 7c9c94b9c8 Cygwin: Raise dumpstack frame limit to 32
Create a #define for the limit and raise it from 16 to 32.
2019-11-08 10:23:08 +01:00
Takashi Yano 3880efb283 Cygwin: console, pty: Prevent error in legacy console mode. 2019-11-08 10:08:45 +01:00
Takashi Yano e5db0d2fe0 Cygwin: pty: Change how to determine if running as service or not. 2019-11-06 15:06:05 +01:00
Corinna Vinschen 44432b93ad Cygwin: document console helper patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-11-05 11:57:32 +01:00
Corinna Vinschen 530b866c8e Cygwin: fix quoting when starting invisible console process
fhandler_console::create_invisible_console_workaround() does not use the
lpApplicationName parameter and neglects to quote its command name on
lpCommandLine in the call to CreateProcessW.

Given CreateProcessW's brain-dead method to evaluate the application
path given on the command line, this opens up a security problem if
Cygwin is installed into a path with spaces in it.

Fix this by using the lpApplicationName parameter and quoting of the
application path in the lpCommandLine parameter (used as argv[0] in
the called console helper.

For extended paranoia, make the argument string array big enough to
fit full 64 bit pointer values into it.  Handles usually only use
the lower 32 bit, but better safe than sorry.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-11-05 11:51:55 +01:00
Corinna Vinschen 7a26e19d4f Cygwin: devices: drop MAX_CONSOLES and fix FH_CONS_MAX
FH_CONS_MAX should refelect the fact that we allow 128 consoles, even if
it's unused.

Suggested-by: Achim Gratz <Stromeko@nexgo.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-11-04 10:34:59 +01:00
Corinna Vinschen 57640bee75 Cygwin: fix process parent/child relationship after execve
Commit 5a0f2c00aa "Cygwin: fork/exec: fix child process permissions"
removed the PROCESS_DUP_HANDLE handle permission of the parent process
handle in the child to avoid a security problem.

It turned out that this broke the following scenario: If a process forks
and then the parent execs, the child loses the ability to register the
parent's death.  To wit, after the parent died the child process does
not set its own PPID to 1 anymore.

The current exec mechanism copies required handle values (handles to
keep contact to the child processes) into the child_info for the
about-to-be-exec'ed process.  The exec'ed process is supposed to
duplicate these handles.  This fails, given that we don't allow the
exec'ed process PROCESS_DUP_HANDLE access to the exec'ing process since
commit 5a0f2c00aa.

The fix is to avoid the DuplicateHandle calls in the exec'ed process.

This patch sets the affected handles to "inheritable" in the exec'ing
process at exec time.  The exec'ed process just copies the handle values
and resets handle inheritance to "non-inheritable".  The exec'ing
process doesn't have to reset handle inheritance, it exits after setting
up the exec'ed process anyway.

Testcase: $ ssh-agent /bin/sleep 3

ssh-agent forks and the parent exec's sleep.  After sleep exits, `ps'
should show ssh-agent to have PPID 1, and eventually ssh-agent exits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-11-02 19:55:24 +01:00
Anton Lavrentiev via cygwin-patches fe239aef1b Cygwin: getpriority() consistent with process priority
https://cygwin.com/ml/cygwin/2019-08/msg00122.html
2019-10-31 21:40:22 +01:00
Achim Gratz 25ce0e1213 Cygwin: Provide more COM devices
Provide for 128 COM devices since Windows likes to create lots of these
over time (one per identifiable device and USB port).
2019-10-23 10:05:42 +02:00
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 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
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
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
Takashi Yano 33a21904a7 Cygwin: console: Add workaround for windows xterm compatible mode bug.
- The horizontal tab positions are broken after resizing console window.
  This seems to be a bug of xterm compatible mode of windows console.
  This workaround fixes this problem.
2019-08-12 17:08:48 +02:00
Takashi Yano 92e2c1ad9d Cygwin: console: Fix deadlock at calling fork().
- Calling fork() on console occasionally falls into deadlock. The reason
  is not clear, however, this patch fixes this problem anyway.
2019-08-12 17:08:48 +02:00
Joel Sherrill eae68bfc87 Add default implementation of fenv.h and all methods
The default implementation of the fenv.h methods return
	-EOPNOTSUP. Some of these have implementations appropriate
        for soft-float.

	The intention of the new fenv.h is that it be portable
	and that architectures provide their own implementation
	of sys/fenv.h.
2019-08-09 17:49:16 +02:00
Corinna Vinschen d59c2c9b82 Cygwin: drop preliminary 3.0.8 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-09 17:49:16 +02:00
Corinna Vinschen 449e9a73d1 Cygwin: add missing bugfix release messages for 3.1.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-09 17:47:55 +02:00
Corinna Vinschen 1f34405fea Cygwin: shmat: use mmap allocator strategy on 64 bit
This avoids collisions of shmat maps with Windows own datastructures
when allocating top-down.

This patch moves the mmap_allocator class definition into its
own files and just uses it from mmap and shmat.
2019-08-08 11:27:52 +02:00
Lavrentiev, Anton 5fa9a0e708 Cygwin: getpriority() and top display for priority is inconsistent
Fix this by aligning /proc/[PID]/stat to the values returned by getpriority().
2019-08-08 09:56:49 +02:00
Michael Haubenwallner 472fbb8b97 Cygwin: build_env: fix off-by-one bug when re-adding PATH
Adding default winvar 'PATH=C:\cygwin64\binZ' to an environment that is
already allocated for 'SYSTEMROOT=ZWINDIR=Z', we need to count that
trailing (Z)ero as well.  Otherwise we trigger this assertion failure:

$ /bin/env -i SYSTEMROOT= WINDIR= /bin/env
assertion "(s - envblock) <= tl" failed: file "/home/corinna/src/cygwin/cygwin-3.0.7/cygwin-3.0.7-1.x86_64/src/newlib-cygwin/winsup/cygwin/environ.cc", line 1302, function: char** build_env(const char* const*, WCHAR*&, int&, bool, HANDLE)
Aborted (core dumped)
2019-08-07 11:08:01 +02:00
Corinna Vinschen 98669a2476 Cygwin: exec: check execute bit prior to evaluating script
When the exec family of functions is called for a script-like
file, the av::setup function handles the exec[vl]p case as
well.  The execve case for files not starting with a she-bang
is handled first by returning ENOEXEC.  Only after that, the
file's executability is checked.

This leads to the problem that ENOEXEC is returned for non-executable
files as well.  A calling shell interprets this as a file it should try
to run as script.  This is not desired for non-executable files.

Fix this problem by checking the file for executability first.  Only
after that, follow the other potential code paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-08-06 10:50:42 +02:00