Commit Graph

12889 Commits

Author SHA1 Message Date
Corinna Vinschen 84ffbfeb10 Cygwin: automake: fix warning in terms of the `ps' target
We are building a ps executable, but the rule to build the target
collides with an auto-generated, documentation-related `ps' rule.

Work around that by naming the executable "cygps" at build time
and use a transform rule to rename it at installation time.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:24:53 +02:00
Jon Turney 0bf0cf48ff Cygwin: specify toollibdir toolincludedir in terms of tooldir
Specify toollibdir and toolincludedir in terms of tooldir, so the
install location is correct if tooldir is the default
($(exec_prefix)/$(target_alias)), or explicitly specified on the 'make'
command line.
2021-04-29 11:20:37 +02:00
Corinna Vinschen a26779fae0 Cygwin: drop all generated autotools files
- add autotool files generated under winsup to .gitignore

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-29 11:16:38 +02:00
Brian Inglis 5eb232ede7 format_proc_cpuinfo: add v_spec_ctrl, bus_lock_detect
Linux 5.12 Frozen Wasteland added features and changes:
add AMD 0x8000000a EDX:20 v_spec_ctrl virtual speculation control support
add Intel 0x00000007 ECX:24 bus_lock_detect bus lock detect debug exception
2021-04-28 12:26:03 +02:00
Corinna Vinschen a89bd73c5f Cygwin: tty.h: devices.h is a local header, not a system header
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-27 21:25:29 +02:00
Jon Turney 247ce0ca3a
Cygwin: Use automake (v5)
v2:
* Include tzmap.h in BUILT_SOURCES
* Make per-file flags appear after user-supplied CXXFLAGS, so they can
override optimization level.
* Correct .o files used to define symbols exported by libm.a
* Drop gcrt0.o mistakenly included in libgmon.a
* Add missing line continuations in GMON_FILES value

v3:
* use per-file flags for .c compilation
* override C{XX,}FLAGS, as they are set on the command line by top-level make

v4:
* Drop -Wno-error=write-strings from path_testsuite CXXFLAGS

v5:
* Update for changes in master
- Add -fno-threadsafe-statics to CXX flags
- Add hypotl.cc
- Remove fenv.cc (in favour of newlib), add fenv.c stub
- Add proc.5 manpage rules
2021-04-27 16:49:56 +01:00
Ken Brown 3b0ba65352 Cygwin: connect: implement resetting a connected DGRAM socket
Following POSIX and Linux, allow a connected DGRAM socket's connection
to be reset (so that the socket becomes unconnected).  This is done by
calling connect and specifing an address whose family is AF_UNSPEC.
2021-04-27 10:01:45 -04:00
Ken Brown 2be07f7554 Cygwin: connect: set connect state for DGRAM sockets
When connect is called on a DGRAM socket, the call to Winsock's
connect can immediately return successfully rather than failing with
WSAEWOULDBLOCK.  Set the connect state to "connected" in this case.

Previously the connect state remained "connect_pending" after the
successful connection.
2021-04-26 09:19:37 -04:00
Takashi Yano 6d46d85049 Cygwin: pty: Add missing guard for close_pseudoconsole().
- This patch adds a missing mutex guard for close_pseudoconsole()
  call when GDB exits.
2021-04-21 17:42:00 +02:00
Takashi Yano 6004ea977b Cygwin: pty: Fix fallback processing in setup_pseudoconsole().
- Currently, the fallback processing in setup_pseudoconsole()
  when helper process error occurs does not work properly.
  This patch fixes the issue.
2021-04-21 17:42:00 +02:00
Takashi Yano 01387f1ff4 Cygwin: pty: Additional race issue fix regarding pseudo console.
- In commit bb93c6d7, the race issue was not completely fixed. In
  the pseudo console inheritance, if the destination process to
  which the ownership of pseudo console switches, is found but exits
  before switching, the inheritance fails. Currently, this extremely
  rarely happens. This patch fixes the issue.
2021-04-21 17:42:00 +02:00
Corinna Vinschen 13fd26ecf5 Cygwin: skip native symlink check in Windows dir under WOW64
Commit 456c3a4638 added a workaround when handling paths with native
symlinks as inner path components.  This patch introduced a problem for
paths handled by the WOW64 File System Redirector (FSR).

Fix this problem by not performing the new code from commit 456c3a4638
for paths under the Windows directory.  Only do this in WOW64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-21 17:41:08 +02:00
Corinna Vinschen 8050ef2074 Cygwin: add 3.2.1 release file and add fixes up to this point
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-20 10:46:39 +02:00
Takashi Yano 5176afeb7d Cygwin: pty: Make rlwrap work with cmd.exe.
- After the commit 919dea66, "rlwrap cmd" fails to start pseudo
  console. This patch fixes the issue.
2021-04-20 10:21:45 +02:00
Takashi Yano bb93c6d7c2 Cygwin: pty: Fix race issue in inheritance of pseudo console.
- If multiple non-cygwin processes are started/ended simultaneously,
  inheritance of pseudo console sometimes fails. This patch fixes
  the issue.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html
2021-04-20 10:21:45 +02:00
Takashi Yano b4fc81edcc Cygwin: console: Fix race issue regarding cons_master_thread().
- With this patch, the race issue regarding starting/stopping
  cons_master_thread() introduced by commit ff4440fc is fixed.

  Addresses:
    https://cygwin.com/pipermail/cygwin/2021-April/248292.html
2021-04-20 10:21:45 +02:00
Takashi Yano a648c15309 Cygwin: console: Fix a bug in the code to fix tab position.
- With this patch, a bug in the code to fix tab position after
  resizing window is fixed.
2021-04-19 16:17:12 +02:00
Corinna Vinschen 456c3a4638 Cygwin: path_conv: Try to handle native symlinks more sanely
For local paths, add a check if the inner path components contain native
symlinks or junctions.  Compare the incoming path with the path returned
by NtQueryInformationFile(FileNameInformation).  If they differ, there
must be at least one native symlink or junction in the path.  If so,
treat the currently evaluated file as non-existant.  This forces
path_conv::check to backtrack inner path components until we eliminated
all native symlinks or junctions and have a normalized path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-19 14:49:14 +02:00
Corinna Vinschen 183e5f0a15 Cygwin: take hypotl function from Mingw-w64
The simple newlib hypotl for real long double architectures is too
simple at this point.  It's implemented as a real call to sqrtl(x^2+y^2).
This has a fatal tendency to overflow for big input numbers.  Hypotl
isn't supposed to do that if the result would still be valid in range of
long double.

Given the complexity of implementing hypotl for various architectures,
we just take the hypotl function from Mingw-w64, which is in the public
domain.

Even though this hypotl is an architecture-independent implementation,
we can't use it for newlib yet, unfortunately, because it requires logbl
under the hood.  Logbl is yet another function missing in newlib for
real long double architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-19 12:39:30 +02:00
Corinna Vinschen 81137c50d1 Cygwin: fix fenv.h includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen cc19109af9 Cygwin: don't export _feinitialise from newlib
Use the more official fesetenv(FE_DFL_ENV) from _dll_crt0, thus
allowing to drop the _feinitialise declaration from fenv.h.

Provide a no-op _feinitialise in Cygwin as exportable symbol for really
old applications when _feinitialise was called from mainCRTStartup in
crt0.o.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Corinna Vinschen 3b22d72255 fenv: drop Cygwin-specific implementation in favor of newlib code
Drop the Cygwin-specific fenv.cc and fenv.h file and use the equivalent
newlib functionality now, so we have at least one example of a user for
this new mechanism.

fenv.c: allow _feinitialise to be called from Cygwin startup code

fenv.h: add declarations for fegetprec and fesetprec for Cygwin only.
        Fix a comment.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-13 12:55:34 +02:00
Ken Brown 436e47584a Cygwin: select: set_bits: fix return value
If a socket descriptor is set to ready for reading on a failed
connect, increment the return value.
2021-04-07 11:43:27 -04:00
Corinna Vinschen ef95c03522 Cygwin: select: Fix FD_CLOSE handling
An FD_CLOSE event sets a socket descriptor ready for writing.
This is incorrect if the FD_CLOSE is a result of shutdown(SHUT_RD).
Only set the socket descriptor ready for writing if the FD_CLOSE
is indicating an connection abort or reset error condition.

This requires to tweak fhandler_socket_wsock::evaluate_events.
FD_CLOSE in conjunction with FD_ACCEPT/FD_CONNECT special cases
a shutdown condition by setting an error code.  This is correct
for accept/connect, but not for select.  In this case, make sure
to return with an error code only if FD_CLOSE indicates a
connection error.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-06 21:35:43 +02:00
Corinna Vinschen caa78917b6 Cygwin: select: don't set ready for exception on socket shutdown
So far select wrongly sets the descriptor as ready for exception
when a shutdown occurs.  This is entirely non-standard.  Only set
this bit on an out-of-band event.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-04-06 21:26:33 +02:00
Takashi Yano 8bb5161fe3 Cygwin: pty: Use atexit() instead of hooking exit() for GDB.
- This patch utilizes atexit() instead of hooking exit() to clean
  up pseudo console stuff when debugging non-cygwin app using GDB.
2021-04-06 12:15:24 +02:00
Takashi Yano ba2fbfec95 Cygwin: pty: Use find_exec() rather than path_conv::check().
- With this patch, find_exec() rather than path_conv::check() is used
  in order to enable searching executable file in the path.
2021-04-06 12:14:36 +02:00
Takashi Yano fdda29fb57 Cygwin: fhandler: Rename handles from XXX_cyg/XXX to XXX/XXX_nat.
- Currently, functions/variables regarding the handles for cygwin
  apps are with "_cyg", and those of handles for non-cygwin apps
  are without "_cyg", such as get_handle_cyg() and get_handle().
  This patch renames these to the names without "_nat" and with
  "_nat" respectively, such as get_handle() and get_handle_nat().
2021-04-06 12:00:37 +02:00
Corinna Vinschen 80cda9bbda Cygwin: bump DLL version to 3.2.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-29 21:00:09 +02:00
Corinna Vinschen f578883232 Cygwin: add "app execution aliases" treatment to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-23 16:54:41 +01:00
Johannes Schindelin 0631c6644e Cygwin: Treat Windows Store's "app execution aliases" as symbolic links
When the Windows Store version of Python is installed, so-called "app
execution aliases" are put into the `PATH`. These are reparse points
under the hood, with an undocumented format.

We do know a bit about this format, though, as per the excellent analysis:
https://www.tiraniddo.dev/2019/09/overview-of-windows-execution-aliases.html

	The first 4 bytes is the reparse tag, in this case it's
	0x8000001B which is documented in the Windows SDK as
	IO_REPARSE_TAG_APPEXECLINK. Unfortunately there doesn't seem to
	be a corresponding structure, but with a bit of reverse
	engineering we can work out the format is as follows:

	Version: <4 byte integer>
	Package ID: <NUL Terminated Unicode String>
	Entry Point: <NUL Terminated Unicode String>
	Executable: <NUL Terminated Unicode String>
	Application Type: <NUL Terminated Unicode String>

Let's treat them as symbolic links. For example, in this developer's
setup, this will result in the following nice output:

	$ cd $LOCALAPPDATA/Microsoft/WindowsApps/

	$ ls -l python3.exe
	lrwxrwxrwx 1 me 4096 105 Aug 23  2020 python3.exe -> '/c/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0/python.exe'

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-03-23 16:54:37 +01:00
Johannes Schindelin 2533912fc7 Cygwin: Allow executing Windows Store's "app execution aliases"
The Windows Store version of Python (and apparently other Windows Store
applications) install a special reparse point called "app execution
alias" into the user's `PATH`.

These applications can be executed without any problem, but they cannot
be read as if they were files. This trips up Cygwin's beautiful logic that
tries to determine whether we're about to execute a Cygwin executable or
not: instead of executing the application, it will fail, saying
"Permission denied".

Let's detect this situation (`NtOpenFile()` helpfully says that this
operation is not supported on this reparse point type), and simply skip
the logic: Windows Store apps are not Cygwin executables (and even if
they were, it is unlikely that they would come with a compatible
`cygwin1.dll` or `msys-2.0.dll`).

This fixes https://github.com/msys2/MSYS2-packages/issues/1943

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2021-03-23 16:54:33 +01:00
Takashi Yano via Cygwin-patches ef05e8bdae Cygwin: pty: Rename input/output named pipes.
- Currently, names of output pipes are "pty%d-to-master" and "pty%d-
  to-master-cyg" and names of input pipes are "pty%d-to-slave" and
  "pty%d-from-master". With this patch, these pipes are renamed to
  "pty%d-to-master-nat", "pty%d-to-master", "pty%d-from-master-nat"
  and "pty%d-from-master" respectively.
2021-03-23 13:18:19 +01:00
Takashi Yano via Cygwin-patches d10d0d9b03 Cygwin: pty: Transfer input only if the stdin is a pty.
- The commit 12325677f7 did not fix enough. With this patch, more
  transfer_input() calls are skipped if stdin is redirected or piped.
2021-03-09 11:21:10 +01:00
Corinna Vinschen 11ae6943eb Cygwin: update release notes for 3.2.0, part 5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-09 11:07:31 +01:00
Corinna Vinschen 1eaa9b08af Cygwin: update release notes for 3.2.0, part 4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-09 10:06:03 +01:00
Takashi Yano via Cygwin-patches 12325677f7 Cygwin: pty: Transfer input for native app only if the stdin is pcon.
- Currently, transfer input is triggered even if the stdin of native
  app is not a pseudo console. With this patch it is triggered only
  if the stdin is a pseudo console.
2021-03-08 16:33:53 +01:00
Ken Brown a9ff2cad68 Cygwin: update release notes for 3.2.0 2021-03-08 09:54:43 -05:00
Takashi Yano via Cygwin-patches 850b5a9aae Cygwin: pty: Attach to stub process when non-cygwin app inherits pcon.
- If two non-cygwin apps are started simultaneously, attaching to
  pseudo console sometimes fails. This is because the second app
  trys to attach to the process not started yet. This patch avoids
  the issue by attaching to the stub process rather than the other
  non-cygwin app.
2021-03-08 15:02:25 +01:00
Corinna Vinschen 07e2ce9f55 Cygwin: update release notes for 3.2.0, part 2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-08 11:40:09 +01:00
Corinna Vinschen abc8acb6a0 Cygwin: update release notes for 3.2.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-08 11:34:46 +01:00
Takashi Yano via Cygwin-patches b92a6303f1 Cygwin: console, pty: Stop ignoring Ctrl-C by IGNBRK.
- Perhaps current code misunderstand meaning of the IGNBRK. As far
  as I investigated, IGNBRK is concerned with break signal in serial
  port but there is no evidence that it has effect to ignore Ctrl-C.
  This patch stops ignoring Ctrl-C by IGNBRK for non-cygwin apps.
2021-03-08 10:33:30 +01:00
Takashi Yano via Cygwin-patches 4e16e575db Cygwin: pty: Discard input already accepted on interrupt.
- Currently, input already accepted is not discarded on interrupt
  by VINTR, VQUIT and VSUSP keys. This patch fixes the issue.
2021-03-08 10:33:30 +01:00
Corinna Vinschen 582628d551 Revert "Cygwin: Make sure newer apps get uname_x even when loading uname dynamically"
This reverts commit 532b91d24e.

It turned out that this patch has undesired side effects.  To wit, if a
newer, post-uname_x executable was linked against or loading an older,
pre-uname_x DLL, and this DLL called uname.  This call would jump into
the old uname with the old struct utsname as parameter, but given the
newer executable it would get redirected to uname_x.  uname_x in turn
would overwrite stack memory it should leave well alone, given it
expects the newer, larger struct utsname.

For the entire discussion see the thread starting at
https://cygwin.com/pipermail/cygwin/2021-February/247870.html
and continuing in March at
https://cygwin.com/pipermail/cygwin/2021-March/247930.html
For a description where we're coming from, see
https://cygwin.com/pipermail/cygwin/2021-March/247959.html

While we *could* make the scenario in question work by patching dlsym,
the problem would actually be the same, just for dynamic loading.  In
the end, we're missing the information, which Cygwin version has been
used when building DLLs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-03-08 10:33:30 +01:00
Takashi Yano via Cygwin-patches 5cf99d2f6e Cygwin: console: Fix restoring console mode failure.
- Restoring console mode fails in the following scenario.
   1) Start cygwin shell in command prompt.
   2) Run 'exec chcp.com'.
  This patch fixes the issue.
2021-03-05 16:11:35 +01:00
Takashi Yano via Cygwin-patches 919dea66d3 Cygwin: pty: Fix a race issue in startup of pseudo console.
- If two non-cygwin apps are started simultaneously and this is the
  first execution of non-cygwin apps in the pty, these occasionally
  hang up. The cause is the race issue between term_has_pcon_cap(),
  reset_switch_to_pcon() and setup_pseudoconsole(). This patch fixes
  the issue.
2021-03-05 15:48:46 +01:00
Ken Brown 182ba1f022 Cygwin: simplify linkat with AT_EMPTY_PATH
linkat(olddirfd, oldpath, oldname, newdirfd, newname, AT_EMPTY_PATH)
is supposed to create a link to the file referenced by olddirfd if
oldname is the empty string.  Currently this is done via the /proc
filesystem by converting the call to

  linkat(AT_FDCWD, "/proc/self/fd/<olddirfd>", newdirfd, newname,
         AT_SYMLINK_FOLLOW),

which ultimately leads to a call to the appropriate fhandler's link
method.  Simplify this by using cygheap_fdget to obtain the fhandler
directly.
2021-02-25 17:44:18 -05:00
Ken Brown 425203384a Cygwin: fix linkat(2) on sockets that are not socket files
If linkat(2) is called with AT_EMPTY_PATH on an AF_LOCAL or
AF_UNIX socket that is not a socket file, the current code calls
fhandler_disk_file::link in most cases.  The latter expects to be
operating on a disk file and uses the socket's io_handle, which
is not a file handle.

Fix this by calling fhandler_disk_file::link only if the
fhandler_socket object is a file (determined by testing
dev().isfs()).

Also fix the case of a socket file opened with O_PATH by setting
the fhandler_disk_file's io_handle.
2021-02-25 17:44:18 -05:00
Ken Brown 012427c96e Cygwin: fix facl on sockets that are not socket files
If facl(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fhandler_disk_file::facl in most
cases.  The latter expects to be operating on a disk file and uses the
socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::facl only if the
fhandler_socket object is a file (determined by testing dev().isfs()).
2021-02-25 17:44:18 -05:00
Ken Brown cb0e71d3f8 Cygwin: fix fchown on sockets that are not socket files
If fchown(2) is called on an AF_LOCAL or AF_UNIX socket that is not a
socket file, the current code calls fhandler_disk_file::fchown in most
cases.  The latter expects to be operating on a disk file and uses the
socket's io_handle, which is not a file handle.

Fix this by calling fhandler_disk_file::fchown only if the
fhandler_socket object is a file (determined by testing dev().isfs()).
2021-02-25 17:44:18 -05:00