Commit Graph

21268 Commits

Author SHA1 Message Date
Jon Turney 57e3e3d3ab
Cygwin: CI: don't run on both main and master refs 2023-08-02 17:25:50 +01:00
Corinna Vinschen c49bc478b4 Cygwin: Add ISO C2X functions c8rtomb, mbrtoc8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Corinna Vinschen 290b56a879 sys/features.h: Define _ISOC2X_SOURCE and __ISO_C_VISIBLE
Add feature test for C2X code. Add matching definitions
_ISOC2X_SOURCE for requesting sources and __ISO_C_VISIBLE
to be used in headers.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Corinna Vinschen 8fbbc668a0 Cygwin: uchar.h: fix definition of uchar16_t and uchar32_t
Per C++11, uchar16_t and uchar32_t are defined the same as
uint_least16_t and uint_least32_t.  Also, check for the C++
version to make sure that the types are not colliding with
predefined c++ types.

Fixes: 4f258c55e8 ("Cygwin: Add ISO C11 functions c16rtomb, c32rtomb, mbrtoc16, mbrtoc32.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-02 16:56:24 +02:00
Takashi Yano 5ac83ea47a newlib: Fix memory leak regarding gdtoa-based _ldtoa_r().
After the commit a4705d387f, printf() for floating-point values
causes a memory leak. The legacy _ldtoa_r() assumed the char pointer
returned will be free'ed by Bfree(). However, gdtoa-based _ldtoa_r()
returns the pointer returned by gdtoa() which should be free'ed by
freedtoa(). Due to this issue, the caller of _ldtoa_r() fails to free
the allocated char buffer. This is the cause of the said memory leak.
https://cygwin.com/pipermail/cygwin/2023-July/254054.html

This patch makes rv_alloc()/freedtoa() allocate/free the buffer in
a compatible way with legacy _ldtoa_r().

Fixes: a4705d387f ("ldtoa: Import gdtoa from OpenBSD.")
Reported-by: natan_b <natan_b@libero.it>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-08-02 15:00:56 +09:00
Corinna Vinschen dedbbd74d0 Cygwin: select: workaround FD_WRITE network event handling
The FD_WRITE event is a false friend.  It indicates ready to write
even if the next send fails with WSAEWOULDBLOCK.  *After* the fact,
FD_WRITE will be cleared until sending is again possible, but that
is too late for a select/write loop.

Workaround that by using the WinSock select function when peeking
at a socket and FD_WRITE gets indicated. WinSock select fortunately
indicates writability correctly.

Fixes: 70e476d27b ("(peek_socket): Use event handling for peeking socket.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-01 14:22:55 +02:00
Corinna Vinschen 0e711d6cc9 Cygwin: autoload: introduce LoadDLLfunc_pfx_only
This macro loads and defines a function just as usual, except
that the Windows function is exposed only with the prefix
_win32_.  So Windows select (the immediate victim) is only
exposed as _win32_select.  That allows to autoload the windows
function without collision with a Cygwin function of the same
name.

For a start, only define the most simple macro, setting all
extensions to 0.


Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-01 14:16:40 +02:00
Corinna Vinschen 4f258c55e8 Cygwin: Add ISO C11 functions c16rtomb, c32rtomb, mbrtoc16, mbrtoc32.
Add uchar.h accordingly.

For the c32 functions, use the internal functions wirtomb and mbrtowi
as base, and convert wirtomb and mbrtowi to inline functions calling
the c32 functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-31 22:39:09 +02:00
Corinna Vinschen 68bb3deabd Cygwin: fix GB18030 support
The changes to support GB18030 were insufficient and the underlying
Windows conversion functions just failed. Fix how the Windows functions
are called for GB18030.

Fixes: 5da71b6059 ("Cygwin: add support for GB18030 codeset")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-31 22:39:09 +02:00
Corinna Vinschen 8a43189438 Revert "* libc/stdlib/mbtowc_r.c (__ascii_mbtowc): Disallow conversion of"
This reverts commit 2b77087a48.

For some reason lost in time, commit 2b77087a48 introduced
Cygwin-specific code treating single byte characters outside the
portable character set as illegal chars.  However, Cygwin was
always alone with this over-correct behaviour and it leads to
stuff like gnulib replacing functions defined in Cygwin with
their own implementation just due to that.

Revert this change, sans the changes to ChangeLog.

Fixes: 2b77087a48 ("* libc/stdlib/mbtowc_r.c (__ascii_mbtowc): Disallow conversion of")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-31 22:39:09 +02:00
Corinna Vinschen 4f78215c86 Cygwin: belatedly bump CYGWIN_VERSION_API_MINOR for new posix_spawn funcs
Commit c743751aaf ("Cygwin: Export
posix_spawn_file_actions_add{f}chdir_np")
added two new functions but we forgot to bump the API version.
Catch up.

Fixes: c743751aaf ("Cygwin: Export posix_spawn_file_actions_add{f}chdir_np")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-31 22:39:09 +02:00
Corinna Vinschen a13b0b7aea Cygwin: fnmatch: fix range comparison in C locale
Commit c36064bbd0 introduced operating on character pointers
instead of operating on characters, to allow collating symbols.
This patch neglected to change the expression for range
comparison in case we're in the C locale.  Thus it suddenly
compared pointers instead of characters.  Fix that.

Fixes: c36064bbd0 ("Cygwin: fnmatch: support collating symbols in [. .] brackets")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-27 21:57:49 +02:00
Jesse Huang via Newlib 9e329b544a Fix rounding results in lrint() & llrint() when close to 0
soft-fp should round floating pointer numbers according to the current
rounding mode. However, in the current code of lrint() and llrint(),
there are if statements before the actual rounding computation

      if(j0 < -1)
        return 0;

Where j0 is the exponent of the floating point number.

It means any number having a exponent less than -1
(i.e. interval (-0.5, 0.5)) will be rounded to 0 regardeless of the
rounding mode.

The bug already fixed in glibc in 2006 by moving the check afterwards
the rounding computation, but still persists in newlib.

This patch fixed it in a similar way to glibc
Ref Commit in glibc: 6624dbc07b5a9fb316ed188ef01f65b8eea8b47c
2023-07-27 11:14:12 +02:00
Corinna Vinschen 4fbcc8c5fe Rename _NL_CTYPE_OUTDIGITSx_MB/WC to _NL_CTYPE_OUTDIGITx_MB/WC
The extended _NL_foo names were originally designed after their GLibc
counterparts.  However, the OUTDIGIT macros were accidentally defined as
OUTDIGITS, plural.  Fix them.

Fixes: d47d5b850b ("Extend locale support to maintain wide char values of native strings")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 19:55:26 +02:00
Kito Cheng via Newlib d572c4482b RISC-V: Support Zfinx/Zdinx extension.
Zfinx/Zdinx are new extensions ratified in 2022, it similar to F/D extensions,
support hard float operation for single/double precision, but the difference
between Zfinx/Zdinx and F/D is Zfinx/Zdinx is operating under general purpose
registers rather than dedicated floating-point registers.

This patch improve the hard float support detection for RISC-V port, so
that Zfinx/Zdinx can have better/right performance.

Co-authored-by: Jesse Huang <jesse.huang@sifive.com>
2023-07-26 15:21:35 +02:00
Corinna Vinschen fcc87263c4 Cygwin: add AT_EMPTY_PATH fix to release message
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 15:14:55 +02:00
Corinna Vinschen f48ce81122 Cygwin: Fix and streamline AT_EMPTY_PATH handling
The GLIBC extension AT_EMPTY_PATH allows the functions fchownat
and fstatat to operate on dirfd alone, if the given pathname is an
empty string.  This also allows to operate on any file type, not
only directories.

Commit fa84aa4dd2 broke this.  It only allows dirfd to be a
directory in calls to these two functions.

Fix that by handling AT_EMPTY_PATH right in gen_full_path_at.
A valid dirfd and an empty pathname is now a valid combination
and, noticably, this returns a valid path in path_ret.  That
in turn allows to remove the additional path generation code
from the callers.

Fixes: fa84aa4dd2 ("Cygwin: fix errno values set by readlinkat")
Reported-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Tested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 15:14:33 +02:00
Corinna Vinschen 0051091999 Cygwin: use new _AT_NULL_PATHNAME_ALLOWED flag
Convert gen_full_path_at to take flag values from the caller, rather
than just a bool indicating that empty paths are allowed.  This is in
preparation of a better AT_EMPTY_PATH handling in a followup patch.

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 15:14:27 +02:00
Corinna Vinschen a891dc7605 Define _AT_NULL_PATHNAME_ALLOWED
Cygwin needs an internal flag to allow specifying an empty pathname
in utimesat (GLIBC extension). We define it in _default_fcntl.h to
make sure we never introduce a value collision accidentally.
While at it, define the values as 16 bit hex values.

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 15:14:22 +02:00
Corinna Vinschen ae03aa7303 Cygwin: gen_full_path_at: drop never reached code
The check if the local variable p is NULL is useless.  The preceeding
code always sets p to a valid pointer, or it crashes if path_ret is
invalid (which would be a bug in Cygwin).

Fixes: c57b57e5c4 ("* cygwin.din: Sort.")
Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26 15:13:47 +02:00
Jon Turney 25d65d6ec0
Cygwin: CI: Upgrade checkout actions to avoid deprecation warning
Also: workaround a problem with actions/checkout's post-run step using
Cygwin git but being incompatible with it. (This would be better solved
by cygwin-install-action having a post-run step to unwind it's PATH
changes, but that's not currently possible)

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-22 17:16:46 +01:00
Jon Turney 2133d91175
Cygwin: CI: Retain test logs as a build artifact
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-22 17:16:44 +01:00
Jon Turney a1ee8a0f05
Cygwin: testsuite: Drop using DejaGnu to run tests
A more sophisticated (and modern) test harness would probably be useful,
but switching to Automake's built-in test harness gets us parallel test
execution, colourization of failures, simplifies matters, seems adequate
for the current testuite, and means we don't need to write any icky Tcl.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-22 17:16:37 +01:00
Corinna Vinschen 971d2dffea Cygwin: get_posix_access: do not merge permissions for just created files
When creating the POSIX ACL rewrite, the code merging permissions from
everyone/group to group/user ACEs was accidentally called for newly
generated files as well.

This could result in broken permissions, if umask used unusual values
like "0100", granted permissions to everyone/group not granted to
group/user.

Make sure to skip permission merging if the file got just created and
we only want to set correct permissions for the first time.

Fixes: bc444e5aa4 ("Reapply POSIX ACL changes.")
Reported-by: Jon Turney <jon.turney@dronecode.org.uk>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-21 21:57:44 +02:00
Jon Turney 8b0b719d49
Cygwin: Fix uninitialized use of fh in strace output in stat_worker()
Move strace output to fix uninitalized use of fh introduced in previous commit.

../../../../src/winsup/cygwin/syscalls.cc: In function ‘int stat_worker(path_conv&, stat*)’:
../../../../src/winsup/cygwin/syscalls.cc:1971:69: error: ‘fh’ may be used uninitialized [-Werror=maybe-uninitialized]

Fixes: 42b44044b3 ("Cygwin: Fix Windows file handle leak in stat("file", -1)")
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-21 14:24:08 +01:00
Jon Turney 42b44044b3
Cygwin: Fix Windows file handle leak in stat("file", -1)
Don't leak a Windows file handle if stat() is called with a valid
filename, but invalid stat buffer pointer.

We do not destroy fh (which closes a Windows handle it has opened) if an
exception happens in the __try block.

Avoid this by re-ordering things so that we don't construct the fhandler
object until after we've attempted to use the struct stat buffer.

Fixes: 73151c54d5 ("syscalls.cc (stat_worker): Don't call build_fh_pc with invalid pc.")
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-21 13:23:33 +01:00
Jon Turney 9fca983916
Cygwin: testsuite: Drop setting TDIRECTORY
Drop setting TDIRECTORY, just use /tmp in the 'test installation' now
that we have it.

This effectively reverts f3ed5f2fe0

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-21 13:23:17 +01:00
Corinna Vinschen a02144808c Cygwin: don't wait infinitely on a pthread cancel event
Starting with commit 42faed4128 ("* thread.h (class pthread): Add bool
member canceled."), pthread::testcancel waits infinitely on cancel_event
after it checked if the canceled variable is set.  However, this might
introduce a deadlock, if the thread calling pthread_cancel is terminated
after setting canceled to true, but before calling SetEvent on cancel_event.

In fact, it's not at all necessary to wait infinitely.  By definition,
the thread is only canceled if cancel_event is set.  The canceled
variable is just a helper to speed up code.  We can safely assume that
the thread hasn't been canceled yet, if canceled is set, but cancel_event
isn't.

Fixes: 42faed4128 ("* thread.h (class pthread): Add bool member canceled.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-18 22:21:36 +02:00
Jeff Johnston 816e9d67be Fix typo. 2023-07-18 13:43:29 -04:00
Jon Turney 938475f6de
Cygwin: testsuite: Make cancel3 and cancel5 more robust
Despite our efforts, sometimes the async cancellation gets deferred.

Notice this by calling pthread_testcancel(), and then try to work out if
async cancellation was ever successful by checking if all threads ran
for the full expected time, or if some were stopped early.

Also, increase the time we allow for the async cancellation to get
delivered to 30 seconds.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-18 16:45:25 +01:00
Jon Turney 89e80d414b
Cygwin: Restore signal handlers on thread cancellation during system()
Add back the restoration of signal handlers modified during system() on
thread cancellation.

Removed in 3cb9da14 which describes it as 'ill-conceived' (additional
context doesn't appear to be available).

We use the internal implementation helpers for the pthread cleanup
chain, so we can neatly tuck it inside the object, and keep the point
when we restore the signal handlers the same. (The
pthread_cleanup_push/pop() functions are implemented as macros which
must appear in the same lexical scope.)

Fixes: 3cb9da1461 ("Put signals on hold and use system_call_cleanup
class to set and restore signals rather than doing it prior to to
running the program.  Remove the ill-conceived pthread_cleanup stuff.")
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-18 16:43:36 +01:00
Jon Turney c431f6b7fe
Cygwin: pthread: Take note of schedparam in pthread_create
Take note of schedparam in any pthread_attr_t passed to pthread_create.

postcreate() (racily, after the thread is actually created), sets the
scheduling priority if it's inherited, but precreate() doesn't store any
scheduling priority explicitly set via a non-default attr to
pthread_create, so schedparam.sched_priority has the default value of 0.

(I think this is another long-standing bug exposed by 4b51e4c1.  Now we
don't lie about the actual thread priority, it's apparent it's not
really being set in this case.)

Fixes testcase priority2.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-18 14:18:45 +01:00
Jordi Sanfeliu 661f9f9c5a Change getlogin() to only check stdin being null 2023-07-17 15:05:35 -04:00
Jon Turney fee0c04e30
Cygwin: testsuite: Drop Adminstrator privileges while running tests
Test access05 and symlink03 expect operations to fail which succeed when
we have Adminstrator privileges.

There's perhaps a bit of incoherency here: some XFAILed tests expect to
run as root (so maybe we need the ability to selectively cygdrop?).

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:48 +01:00
Jon Turney 10e50f9617
Cygwin: testsuite: Minor fixes to umask03
Change TCIDs to they match the filename
Fix use of "%0" rather than "%o"
Record failure on mismatched permissions, rather than immediately breaking

See ltp commits fa31d55d, 923b23ff and b846e7bb

fa31d55d34
923b23ff1f
b846e7bb9c

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:47 +01:00
Jon Turney 0e8227bbb7
Cygwin: testsuite: Fix a buffer overflow in symlink01
full_path needs to hold a overlong pathname of length PATH_MAX+1, plus a
terminating null.

See ltp commit 44d51c3f

44d51c3f06

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:46 +01:00
Jon Turney e867f8c3e8
Cygwin: testsuite: Busy-wait in cancel3 and cancel5
These tests async thread cancellation of a thread that doesn't have any
cancellation points.

Unfortunately, since 2b165a45 the async cancellation silently fails when
the thread is inside the kernel function Sleep(), so it just exits
normally after 10 seconds. (See the commentary in pthread::cancel() in
thread.cc, where it checks if the target thread is inside the kernel,
and silently converts the cancellation into a deferred one)

Work around this by busy-waiting rather than Sleep()ing for 10 seconds.

This is still somewhat fragile: the async cancel could still fail, if it
happens to occur while we're inside the kernel function that time()
calls.

v2:
Do nothing more efficiently

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:45 +01:00
Jon Turney 7d50e65a84
Cygwin: testsuite: Fix for limited thread priority values
Since commit 4b51e4c1, we return the actual thread priority, not what we
originally stored in the thread attributes.

Windows only supports 7 thread priority levels, which we map onto the 32
required by POSIX.  So, only a subset of values will be returned exactly
by by pthread_getschedparam() after pthread_setschedparam().

Adjust tests priority1, priority2 and inherit1 so they only check for
round-tripping priority values which can be exactly represented.

For CI, this needs to handle process priority class "below normal
priority" as well.

Also check that the range of priority values is at least 32, as required
by POSIX.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:44 +01:00
Jon Turney 79a9288434
Cygwin: testsuite: Also check direct call in systemcall
Check direct call to system(), as well as one in a subprocess.

(This is a lot easier to debug when it's completely broken by the
environment the test is running in)

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:43 +01:00
Jon Turney 7c0750e962
Cygwin: testsuite: Just log result of second open of /dev/dsp
Do not rate successful second open of /dev/dsp as an error, just log the
result.

Based on this patch by Gerd Spalink:

https://cygwin.com/pipermail/cygwin-patches/2004q3/004848.html
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:42 +01:00
Jon Turney 9776357323
Cygwin: testsuite: Skip devdsp test when no audio devices present
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:41 +01:00
Jon Turney 04326f999b
Cygwin: testsuite: Remove const from writable string in fcntl07b
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:39 +01:00
Jon Turney 328258eba4
Cygwin: testsuite: Add a simple timeout mechanism
Astonishingly, we don't have this already, so tests which hang just stop
the testsuite dead in it's tracks...

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:38 +01:00
Jon Turney e8c1a579cd
Cygwin: testsuite: Setup test prereqs in 'installation' the tests run in
Do some setup in the Cygwin 'installation' at testsuite/testinst/:

* Ensure /tmp exists

* Use BusyBox to provide executables needed by tests which use system()
(sh, sleep, ls)

This enables tests which use system(), or require /tmp to exist to pass.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2023-07-14 14:02:37 +01:00
Alexey Lapshin b7c3a63bb3 newlib: posix: add HAVE_OPENDIR build condition for [n]ftw.c 2023-07-13 19:58:29 +02:00
Mark Geisert c836d26d76 Cygwin: Update release/3.4.8 for latest <sys/cpuset.h> commit 2023-07-13 12:15:37 +02:00
Mark Geisert 3f2790e044 Cygwin: Make gcc-specific code in <sys/cpuset.h> compiler-agnostic
The current version of <sys/cpuset.h> cannot be compiled by Clang due to
the use of builtin versions of malloc, free, and memset.  Their presence
here was a dubious optimization anyway, so their usage has been
converted to standard library functions.

The use of __builtin_popcountl remains because Clang implements it just
like gcc does.  If/when some other compiler (Rust? Go?) runs into this
issue we can deal with specialized handling then.

The "#include <sys/cdefs>" here to define __inline can be removed since
both of the new includes sub-include it.

Addresses: https://cygwin.com/pipermail/cygwin/2023-July/253927.html
Fixes: 9cc910dd33a5 (Cygwin: Make <sys/cpuset.h> safe for c89 compilations)
Signed-off-by: Mark Geisert <mark@maxrnd.com>
2023-07-10 10:42:24 +02:00
Takashi Yano b03601a671 Cygwin: fstat(): Fix st_rdev returned by fstat() for /dev/tty.
While st_rdev returned by fstat() for /dev/tty should be FH_TTY,
the current cygwin1.dll returns FH_PTYS+minor or FH_CONS+minor.
Similarly, fstat() does not return correct value for /dev/console,
/dev/conout, /dev/conin or /dev/ptmx.

This patch fixes the issue by:
1) Introduce dev_referred_via in fhandler_termios.
2) Add new argument, which has dev_t value referred by open(),
  for constructors of fhandler_pty_slave and fhandler_pty_master to
  set the value of dev_referred_via.
3) Set st_rdev using dev_referred_via in fhandler_termios::fstat()
  if it is available.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-07-08 08:03:22 +09:00
Takashi Yano 3edb55af82 Cygwin: stat(): Fix "Bad address" error on stat() for /dev/tty.
As reported in
https://cygwin.com/pipermail/cygwin/2023-June/253888.html,
"Bad address" error occurs when stat() is called after the commit
3721a756b0 ("Cygwin: console: Make the console accessible from
other terminals.").

There are two problems in the current code. One is fhandler_console::
fstat() calls get_ttyp()->getsid(). However, fh_alloc() in dtable.cc
omits to initialize the fhandler_console instance when stat() is
called. Due to this, get_ttyp() returns NULL and access violation
occurs. The other problem is fh_alloc() assigns fhandler_console
even if the CTTY is not a console. So the first problem above occurs
even if the CTTY is a pty.

This patch fixes the issue by:
1) Call set_unit() to initialize _tc if the get_ttyp() returns NULL.
2) Assign fhandler_pty_slave for /dev/tty if CTTY is a pty in fh_alloc().

Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible
  from other terminals.").
Fixes: 23771fa1f7 ("dtable.cc (fh_alloc): Make different decisions
  when generating fhandler for not-opened devices. Add kludge to deal
  with opening /dev/tty.")
Reported-by: Bruce Jerrick <bmj001@gmail.com>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2023-07-08 08:03:16 +09:00
Corinna Vinschen e38f91d5a9 Cygwin: Fix latest release message being in the wrong release file.
Fixes: 6422e76637 ("Cygwin: Make <sys/cpuset.h> safe for c89 compilations")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-04 16:50:37 +02:00