4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-02 12:30:24 +08:00

19775 Commits

Author SHA1 Message Date
Ken Brown
23b6a6c782 Cygwin: sysconf, getrlimit: don't call getdtablesize
Now that getdtablesize always returns OPEN_MAX_MAX, we can simplify
sysconf(_SC_OPEN_MAX) and getrlimit(RLIMIT_NOFILE) to just use that
same constant instead of calling getdtablesize.
2021-02-01 12:16:54 -05:00
Ken Brown
6ae15c77a0 Cygwin: getdtablesize: always return OPEN_MAX_MAX
According to the Linux man page for getdtablesize(3), the latter is
supposed to return "the maximum number of files a process can have
open, one more than the largest possible value for a file descriptor."
The constant OPEN_MAX_MAX is the only limit enforced by Cygwin, so we
now return that.

Previously getdtablesize returned the current size of cygheap->fdtab,
Cygwin's internal file descriptor table.  But this is a dynamically
growing table, and its current size does not reflect an actual limit
on the number of open files.

With this change, gnulib now reports that getdtablesize and
fcntl(F_DUPFD) work on Cygwin.  Packages like GNU tar that use the
corresponding gnulib modules will no longer use gnulib replacements on
Cygwin.
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
62334dffd7 Cygwin: exceptions.cc: Suspend all threads in sig_handle_tty_stop().
- Currently, thread created by pthread_create() is not suspended by
  the signal SIGTSTP. For example, even if a process with a thread
  is suspended by Ctrl-Z, the thread continues running. This patch
  fixes the issue.
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
e78f097efd Cygwin: console: Align the behaviour against signal with pty.
- Currently, read() returns -1 with EINTR if the process is suspended
  by Ctrl-Z and resumed by fg command, while pty continues to read.
  For example, xxd command stops with error "Interrupted system call"
  after Ctrl-Z and fg. This patch aligns the behaviour with pty (and
  Linux).
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
43735b01e6 Cygwin: pty: Make slave read() thread-safe.
- Currently slave read() is somehow not thread-safe. This patch
  fixes the issue.
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
5ef4fd5548 Cygwin: console: Make read() thread-safe.
- Currently read() is somehow not thread-safe. This patch fixes
  the issue.
2021-02-01 12:16:54 -05:00
Ken Brown
4ddd4acf04 Cygwin: fchmodat: add limited support for AT_SYMLINK_NOFOLLOW
Allow fchmodat with the AT_SYMLINK_NOFOLLOW flag to succeed on
non-symlinks.  Previously it always failed, as it does on Linux.  But
POSIX permits it to succeed on non-symlinks even if it fails on
symlinks.

The reason for following POSIX rather than Linux is to make gnulib
report that fchmodat works on Cygwin.  This improves the efficiency of
packages like GNU tar that use gnulib's fchmodat module.  Previously
such packages would use a gnulib replacement for fchmodat on Cygwin.
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
af393860f5 Cygwin: pty: Allow multiple apps to enable pseudo console simultaneously.
- After commit bb428520, there has been the disadvantage:
  7) Pseudo console cannot be activated if it is already activated for
     another process on same pty.
  This patch clears this disadvantage.
2021-02-01 12:16:54 -05:00
Takashi Yano via Cygwin-patches
7c41c4a77b Cygwin: pty: Make apps using console APIs be able to debug with gdb.
- After commit bb428520, there has been the disadvantage:
  2) The apps which use console API cannot be debugged with gdb. This
     is because pseudo console is not activated since gdb uses
     CreateProcess() rather than exec(). Even with this limitation,
     attaching gdb to native app, in which pseudo console is already
     activated, works.
  This patch clears this disadvantage.
2021-02-01 12:16:53 -05:00
Takashi Yano via Cygwin-patches
9f783a84f5 Cygwin: pty: Keep code page between non-cygwin apps.
- After commit bb428520, there has been the disadvantage:
  4) Code page cannot be changed by chcp.com. Acctually, chcp works
     itself and changes code page of its own pseudo console.  However,
     since pseudo console is recreated for another process, it cannot
     inherit the code page.
  This patch clears this disadvantage.
2021-02-01 12:16:53 -05:00
Takashi Yano via Cygwin-patches
0ed1104b9a Cygwin: pty: Inherit typeahead data between two input pipes.
- PTY has a problem that the key input, which is typed during windows
  native app is running, disappears when it returns to shell. This is
  beacuse pty has two input pipes, one is for cygwin apps and the other
  one is for native windows apps. The key input during windows native
  program is running is sent to the second input pipe while cygwin
  shell reads input from the first input pipe. This issue had been
  fixed once by commit 29431fcb, however, the new implementation of
  pseudo console support by commit bb428520 could not inherit this
  feature. This patch realize transfering input data between these
  two pipes bidirectionally by utilizing cygwin-console-helper process.
  The helper process is launched prior to starting the non-cygwin app,
  however, exits immediately unlike previous implementation.
2021-02-01 12:16:53 -05:00
Corinna Vinschen
0ef6b1ec59 Cygwin: Align *utime*() with POSIX/glibc
Followup to previous patch, this time matching definitions in Cygwin

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-02-01 12:16:53 -05:00
Sebastian Huber
851e303442 Align *utime*() with POSIX/glibc
Change the prototypes to be in line with POSIX/glibc.  This may fix
issues with new warnings produced by GCC 11.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2021-02-01 12:16:53 -05:00
Ken Brown
7edc74562d Cygwin: chown: make sure ctime gets updated when necessary
Following POSIX, ensure that ctime is updated if chown succeeds,
unless the new owner is specified as (uid_t)-1 and the new group is
specified as (gid_t)-1.  Previously, ctime was unchanged whenever the
owner and group were both unchanged.

Aside from POSIX compliance, this fix makes gnulib report that chown
works on Cygwin.  This improves the efficiency of packages like GNU
tar that use gnulib's chown module.  Previously such packages would
use a gnulib replacement for chown on Cygwin.
2021-01-26 09:42:16 -05:00
Ben Wijen
7425218eee syscalls.cc: Deduplicate remove
The remove code is already in the _remove_r function.
So, just call the _remove_r function.
2021-01-26 09:42:16 -05:00
Takashi Yano via Cygwin-patches
0a7e412a19 Cygwin: console: Add missing guard regarding attach_mutex.
- The commit a5333345 did not fix the problem enough. This patch
  provides additional guard for the issue.
2021-01-26 09:42:16 -05:00
Ben Wijen
71c112d641 syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
I think we don't need an extra flag as we can utilize: access & FILE_WRITE_ATTRIBUTES
What do you think?

Ben Wijen (1):
  syscalls.cc: unlink_nt: Try FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE

 winsup/cygwin/ntdll.h     |  3 ++-
 winsup/cygwin/syscalls.cc | 22 +++++++--------
 winsup/cygwin/wincap.cc   | 11 ++++++++
 winsup/cygwin/wincap.h    | 56 ++++++++++++++++++++-------------------
 4 files changed, 53 insertions(+), 39 deletions(-)

--
2.30.0

>From 2d0ff6fec10d03c24d11c747852018b7bc1136ac Mon Sep 17 00:00:00 2001
In-Reply-To: <20210122105201.GD810271@calimero.vinschen.de>
References: <20210122105201.GD810271@calimero.vinschen.de>
From: Ben Wijen <ben@wijen.net>
Date: Tue, 17 Dec 2019 15:15:25 +0100
Subject: [PATCH v3 1/8] syscalls.cc: unlink_nt: Try
 FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE

Implement wincap.has_posix_unlink_semantics_with_ignore_readonly and when set
skip setting/clearing of READONLY attribute and instead use
FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE
2021-01-26 09:42:16 -05:00
Ken Brown
11fff7a652 Cygwin: ptsname_r: always return an error number on failure
Return EBADF on a bad file descriptor.  Previously 0 was returned, in
violation of the requirement in
https://man7.org/linux/man-pages/man3/ptsname_r.3.html that an error
number should be returned on failure.

We are intentionally deviating from Linux, on which ENOTTY is
returned.

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00245.html
2021-01-23 12:13:59 -05:00
Ken Brown
ad1033e439 Cygwin: normalize_posix_path: fix error handling when .. is encountered
When .. is in the source path and the path prefix exists but is not a
directory, return ENOTDIR instead of ENOENT.  This fixes a POSIX
compliance issue for realpath(3):

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html

Addresses: https://lists.gnu.org/archive/html/bug-gnulib/2021-01/msg00214.html
2021-01-23 12:13:59 -05:00
Ben Wijen
a1a16ef5d4 Cygwin: Move post-dir unlink check
Move post-dir unlink check from fhandler_disk_file::rmdir to
_unlink_nt_post_dir_check

If a directory is not removed through fhandler_disk_file::rmdir
we can now make sure the post dir check is performed.
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
44b751b0c3 Cygwin: console: Fix "Bad file descriptor" error in script command.
- After the commit 72770148, script command exits occasionally with
  the error "Bad file descriptor" if it is started in console on Win7
  and non-cygwin process is executed. This patch fixes the issue.
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
21005ea642 Cygwin: pty: Reduce buffer size in get_console_process_id().
- The buffer used in get_console_process_id(), introduced by commit
  72770148, is too large and ERROR_NOT_ENOUGH_MEMORY occurs in Win7.
  Therefore, the buffer size has been reduced.
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
c91d8e636b Cygwin: pty: Lessen the side effect of workaround for rlwarp.
- This patch lessens the side effect of the workaround for rlwrap
  introduced by commit 4e16b033.
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
55c4162360 Cygwin: spawn.cc: Fix typo in comment by commit 974e6d76. 2021-01-23 12:13:59 -05:00
Corinna Vinschen
cc0b331bef Cygwin: rmdir: handle /dev in fhandler_dev::rmdir
The isdev_dev check in rmdir is unclean.  Create a virtual method
fhandler_dev::rmdir to handle this transparently.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-01-23 12:13:59 -05:00
Ken Brown
3359ffa276 Cygwin: document a recent bug fix
This documents commit aec64798, "Cygwin: add flag to indicate reparse
points unknown to WinAPI".
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
815bc23ca3 Cygwin: pty: Set input_available_event only for cygwin pipe.
- cat exits immediately in the following senario.
    1) Execute env CYGWIN=disable_pcon script
    2) Execute cmd.exe
    3) Execute cat in cmd.exe.
  This is caused by setting input_available_event for the pipe for
  non-cygwin app. This patch fixes the issue.
2021-01-23 12:13:59 -05:00
Takashi Yano via Cygwin-patches
ea3f6daab4 Cygwin: pty: Make master thread functions be static.
- The functions pty_master_thread() and pty_master_fwd_thread()
  should be static (i.e. should not access class member) because
  the instance is deleted if the master is dup()'ed and the first
  master is closed. In this case, because the dup()'ed instance
  still exists, these master threads are also still alive even
  though the instance has been deleted. As a result, accesing
  class members in these functions causes accessi violation.

  Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2021-January/012030.html
2021-01-23 12:13:58 -05:00
Takashi Yano via Cygwin-patches
652edb0299 Cygwin: pty: Prevent pty from changing code page of parent console.
- After commit 232fde0e, pty changes console code page when the first
  non-cygwin app is executed. If pty is started in real console device,
  pty changes the code page of root console. This causes very annoying
  result because changing code page changes the font of command prompt
  if console is in legacy mode. This patch avoids this by creating a
  new invisible console for the first pty started in console device.
2021-01-23 12:13:58 -05:00
Ben Wijen
b1ea88e6e6 cxx.cc: Fix dynamic initialization for static local variables
The old implementation for __cxa_guard_acquire did not return 1,
therefore dynamic initialization was never performed.

If concurrent-safe dynamic initialisation is ever needed, CXX ABI
must be followed when re-implementing __cxa_guard_acquire (et al.)
2021-01-23 12:13:58 -05:00
Ben Wijen
6fd8636576 syscalls.cc: Use EISDIR
This is the non-POSIX value returned by Linux since 2.1.132.
2021-01-23 12:13:58 -05:00
Ben Wijen
25d2148bbe syscalls.cc: Fix num_links
NtQueryInformationFile on fh_ro needs FILE_READ_ATTRIBUTES
to succeed.
2021-01-23 12:13:58 -05:00
Corinna Vinschen
7c4c9778fe Cygwin: Add Ben Wijen to list of contributors
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2021-01-23 12:13:58 -05:00
Takashi Yano via Cygwin-patches
24c4e80183 Cygwin: pty: Make close_pseudoconsole() be a static member function.
- The function close_pseudoconsole() should be static so that it
  can be safely called in spawn.cc even after the fhandler_pty_slave
  instance has been deleted. That is, there is a problem with the
  current code. This patch fixes the issue.
2021-01-23 12:13:58 -05:00
Takashi Yano via Cygwin-patches
8b10562b57 Cygwin: console: Revise the code to switch xterm mode.
- If application changes the console mode, mode management introduced
  by commit 10d8c278 will be corrupted. For example, stdout of jansi
  v2.0.1 or later is piped to less, jansi resets the xterm mode flag
  ENABLE_VIRTUAL_TERMINA_PROCESSING when jansi is terminated. This
  causes garbled output in less because less needs this flag enabled.
  This patch fixes the issue.
2021-01-23 12:13:58 -05:00
Takashi Yano via Cygwin-patches
963343f888 Cygwin: pty: Add workaround for rlwrap 0.40 or later.
- The workaround for rlwrap introduced by commit 8199b0cc does not
  take effect for rlwrap 0.40 or later. This patch add a workaround
  for rlwrap 0.40 or later as well.
2021-01-23 12:13:58 -05:00
Ken Brown
494d7f81da Cygwin: fstatat: call fstat64 instead of fstat
This fixes a bug on 32-bit Cygwin that was introduced in commit
84252946, "Cygwin: fstatat, fchownat: support the AT_EMPTY_PATH flag".

Add a comment explaining why fstat should not be called.

Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247399.html
2021-01-23 12:13:58 -05:00
Ken Brown
a2e279eb68 Cygwin: AF_UNIX: update tests 2021-01-07 13:58:58 -05:00
Ken Brown
6841fcb82f Cygwin: AF_UNIX: SCM_RIGHTS: support pty master descriptors
This requires modifying fhandler_pty_master::dup so that it duplicates
handles when it is called with non-zero src_pid on an fhandler that
doesn't yet have an archetype.
2021-01-07 13:58:58 -05:00
Sebastian Huber
fcaa3a863a RTEMS: Add <poll.h> and <sys/poll.h>
Add the POSIX header file <poll.h> which is used by the GCC 11 Ada
runtime support.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2021-01-07 13:58:58 -05:00
Ken Brown
89ef52df63 Cygwin: poll(2): extend the socket code to all sockets
poll has code that checks whether a socket descriptor has a failed
connect or whether shutdown has been called.  This previously worked
only for wsock sockets.  Tweak the code so that it applies to all
sockets.

To help with this, add a virtual saw_shutdown_read method to the
fhandler_socket class, and define a version of it for AF_UNIX sockets.
A version for wsock sockets already existed.

Untested.
2020-12-29 11:36:16 -05:00
Ken Brown
953308f403 Cygwin: AF_UNIX: update tests 2020-12-28 14:01:30 -05:00
Ken Brown
1b4df3a0be Cygwin: AF_UNIX: code simplification
When duplicating handles in fhandler_pty_slave::dup, there's no need
to use local handles as in fhandler_pty_slave::open.  We can just
directly use the accessors get_handle, get_handle_cyg, etc.
2020-12-23 11:59:36 -05:00
Jeff Johnston
f24ce1da03 Bump up newlib version to 4.1.0 2020-12-23 11:59:36 -05:00
Paul Zimmermann
8169276058 fixes to make compilation succeeds 2020-12-18 16:53:19 -05:00
Jeff Johnston
dad02bce3a Update gamma functions from code in picolibc
- fixes issue with inf sign when x is -0
2020-12-18 16:53:19 -05:00
Brian Inglis
b0593cf5fd fhandler_proc.cc(format_proc_cpuinfo): report Intel SGX bits
Update to Linux next 5.10 cpuinfo flags for Intel SDM 36.7.1 Software
Guard Extensions, and 38.1.4 SGX Launch Control Configuration.
Launch control restricts what software can run with enclave protections,
which helps protect the system from bad enclaves.
2020-12-18 16:53:19 -05:00
Craig Blackmore
633f39361c RISC-V: Add semihosting support 2020-12-18 16:53:19 -05:00
Jeff Johnston
333317dedb Add declarations for __ieee754_tgamma functions to fdlibm.h 2020-12-18 16:53:18 -05:00
Takashi Yano via Cygwin-patches
7fa9adb2ac Cygwin: pty: Revise the workaround for rlwrap.
- Previous workaround has a problem that screen is distorted if up
  arrow key is pressed at the first line after running "rlwrap cmd".
  This patch fixes the issue.
2020-12-18 16:53:18 -05:00