aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/local_includes
AgeCommit message (Collapse)AuthorFilesLines
2025-08-30Cygwin: pty: Fix FLUSHO handlingTakashi Yano2-2/+0
Previsouly, FLUSHO did not work correctly. 1) Even when FLUSHO is set, read() returns with undesired data in the pipe if select() is called in advance. 2) FLUSHO is toggled even in the case pseudo console enabled. Due to these problems, read data in the pty master was partially lost when Ctrl-O is pressed. With this patch, the mask_flusho flag, that was introduced by the commit 9677efcf005a and caused the issue 1), has been dropped and select() and read() for pty master discards the pipe data instead if FLUSHO flag is set. In addition, FLUSHO handling in the case pseudo console activated is disabled. Addresses: https://cygwin.com/pipermail/cygwin/2025-August/258717.html Fixes: 2cab4d0bb4af ("Cygwin: pty, console: Refactor the code processing special keys.") Fixes: 9677efcf005a ("Cygwin: pty: Make FLUSHO and Ctrl-O work.") Reported-by: Reported-by: Thomas Wolff <towo@towo.net> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-08-18Cygwin: spawn: Make ch_spwan_local be initialized properlyTakashi Yano1-1/+2
The class child_info_spawn has two constructors: one without arguments and one with two arguments. The former does not initialize any members. Commit 1f836c5f7394 used the latter to ensure that the local ch_spawn (i.e., ch_spawn_local) would be properly initialized. However, this was insufficient - it initialized only the base child_info members, not the fields specific to child_info_spawn. This led to the issue reported in https://cygwin.com/pipermail/cygwin/2025-August/258660.html. This patch introduces a new constructor to properly initialize member variable 'ev', etc., which were referred without initialization, and switches ch_spawn_local to use it. 'subproc_ready', which may not be initialized, is also initialized in the constructor of the base class child_info. Addresses: https://cygwin.com/pipermail/cygwin/2025-August/258660.html Fixes: 1f836c5f7394 ("Cygwin: spawn: Make system() thread-safe") Reported-by: Denis Excoffier <cygwin@Denis-Excoffier.org> Reviewed-by: Jeremy Drake <cygwin@jdrake.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-07-30Cygwin: add wrappers for newer new/delete overloadsJeremy Drake1-0/+14
A sized delete (with a std::size_t parameter) was added in C++14 (but doesn't combine with nothrow_t) An aligned new/delete (with a std::align_val_t parameter) was added in C++17, and combinations with the sized delete and nothrow_t variants. Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-07-24Cygwin: Fix handling of archetype fhandler in process_fdTakashi Yano1-0/+1
Previously, process_fd failed to correctly handle fhandlers using an archetype. This was due to the missing PATH_OPEN flag in path_conv, which caused build_fh_pc() to skip archetype initialization. The root cause was a bug where open() did not set the PATH_OPEN flag for fhandlers using an archetype. This patch introduces a new method, path_conv::set_isopen(), to explicitly set the PATH_OPEN flag in path_flags in fhandler_base:: open_with_arch(). Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258167.html Fixes: 92ddb7429065 ("(build_pc_pc): Use fh_alloc to create. Set name from fh->dev if appropriate. Generate an archetype or point to one here.") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-07-23Cygwin: cygheap: Add lock()/unlock() methodTakashi Yano1-0/+5
...so that cygheap can be locked/unlocked from outside of mm/cygheap.cc. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-07-17Cygwin: reg_key: add a method get_binary() to fetch REG_BINARY dataCorinna Vinschen1-0/+2
This patch is required for a followup patch fetching the leap seconds info from the registry starting with Windows 10 1803. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-07-16Cygwin: clocks: Implement CLOCK_TAICorinna Vinschen1-0/+13
CLOCK_TAI is like CLOCK_REALTIME ignoring leap secs. Right now, 2025, it has a positive 37 secs offset from CLOCK_REALTIME. Given the unpredictability of adding leap secs by the IERS (International Earth Rotation and Reference Systems Service), we also add a mechanism to read the current leap secs offset from /usr/share/zoneinfo/leapseconds, part of the tzdata package. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-07-14Cygwin: signal: make context structures registers handling portableRadek Bartoň1-0/+25
This patch extracts macros from winsup/cygwin/exceptions.cc serving for portable register access to context structures into a separate local header winsup/cygwin/local_includes/register.h and implements their AArch64 counterparts. Then, it adds AArch64 declaration of __mcontext structure based on mingw-w64-headers/include/winnt.h header to winsup/cygwin/include/cygwin/singal.h header. Then, it includes the registers.h header and uses the macros where applicable, namely at: - winsup/cygwin/exceptions.cc - winsup/cygwin/profil.c - winsup/cygwin/tread.cc The motivation is to make usage of the context structures portable without unnecessary #if defined(__x86_64__) while implementations of signal handling code will be developed later, e.g. implementation of makecontext. Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-07-14Cygwin: pty: TCIFLUSH also clears readahead buffer in the masterTakashi Yano1-0/+1
Previously, TCIFLUSH flushed the pipe to_slave which transfers input from master to slave. However, this was not sufficiant. The master side holds input data before accept_input() in the read-ahead buffer. So, if input data before 'enter' key can be leaked into slave input after TCIFLUSH. With this patch, TCIFLUSH requests master to flush read-ahead buffer via master control pipe. To realize this, add cmd filed to pipe_request structure so that the flush request can be distinguished from existing pipe handle request. Addresses: https://cygwin.com/pipermail/cygwin/2025-July/258442.html Fixes: 41946df6111b (" (fhandler_tty_slave::tcflush): Implement input queue flushing by calling read with NULL buffer.") Reported-by: Christoph Reiter <reiter.christoph@gmail.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-07-01Cygwin: pipe: Fix unexpected blocking mode change by pipe_data_available()Takashi Yano1-0/+3
ipipe_data_available() is called from raw_write(). If the pipe is in real_non_blocking_mode at that time, calling pipe_data_available() can, in some cases, inadvertently revert the pipe to blocking mode. Here is the background: pipe_data_available() checks the amount of writable space in the pipe by calling NtQueryInformationFile() with the FilePipeLocalInformation parameter. However, if the read side of the pipe is simultaneously consuming data with a large buffer, NtQueryInformationFile() may return 0 for WriteQuotaAvailable. As a workaround for this behavior, pipe_data_available() temporarily attempts to change the pipe-mode to blocking. If the pipe contains data, this operation fails-indicating that the pipe is full. If it succeeds, the pipe is considered empty. The problem arises from the assumption that the pipe is always in real blocking mode before attempting to flip the mode. However, if raw_write() has already set the pipe to non-blocking mode due to its failure to determine available space, two issues occur: 1) Changing to non-blocking mode in pipe_data_available() always succeeds, since the pipe is already in non-blocking mode. 2) After this, pipe_data_available() sets the pipe back to blocking mode, unintentionally overriding the non-blocking state required by raw_write(). This patch addresses the issue by having pipe_data_available() check the current real blocking mode, temporarily flip the pipe-mode and then restore the pipe-mode to its original state. Addresses: https://github.com/git-for-windows/git/issues/5682#issuecomment-2997428207 Fixes: 7ed9adb356df ("Cygwin: pipe: Switch pipe mode to blocking mode by default") Reported-by: Andrew Ng <andrew.ng@sony.com> Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-07-01Cygwin: pipe: Make pipe_data_available() return PDA_UNKNOWNTakashi Yano1-0/+3
... rather than 1 when the pipe space estimation fails, so that select() and raw_wrie() can perform appropriate fallback handling. In select(), even if pipe space is unknown, return writable to avoid deadlock. Even with select() returns writable, write() can blocked anyway, if data is larger than pipe space. In raw_write(), if the pipe is real non-blocking mode, attempting to write larger data than pipe space is safe. Otherwise, return error. For other cases than FH_PIPEW, PDA_UNKNOWN never orrurs. Therefore, it is not necessary to handle it in that cases. Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-06-26Cygwin: signal: Do not suspend myself and use VEHTakashi Yano2-0/+3
After the commit f305ca916ad2, some stress-ng tests fail in arm64 windows. There seems to be two causes for this issue. One is that calling SuspendThread(GetCurrentThread()) may suspend myself in the kernel. Branching to sigdelayed in the kernel code does not work as expected as the original _cygtls::interrup_now() intended. The other cause is, single step exception sometimes does not trigger exception::handle() for some reason. Therefore, register vectored exception handler (VEH) and use it for single step exception instead. Addresses: https://cygwin.com/pipermail/cygwin/2025-June/258332.html Fixes: f305ca916ad2 ("Cygwin: signal: Prevent unexpected crash on frequent SIGSEGV") Reported-by: Jeremy Drake <cygwin@jdrake.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-06-19Cygwin: implement spinlock pause for AArch64Radek Bartoň1-1/+4
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-06-19Cygwin: obtain stack pointer on AArch64Radek Bartoň1-0/+6
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-06-18Cygwin: fix MALLOC_ALIGNMENT already defined in newlib for AArch64Radek Bartoň1-0/+3
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-06-18Cygwin: fix compatibility with GCC 15Radek Bartoň2-6/+6
Signed-off-by: Radek Bartoň <radek.barton@microsoft.com>
2025-06-17Cygwin: signal: Revert _cygtls::inside_kernel() changeTakashi Yano1-1/+1
This patch partially reverts the commit b7097ab39ed0 because it seems to cause issues when longjmp is used within a signal handler. The problem that the commit addressed no longer occurs even if this change is reverted. Fixes: b7097ab39ed0 ("Cygwin: signal: Revive toggling incyg flag in call_signal_handler()") Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-06-17Cygwin: signal: Prevent unexpected crash on frequent SIGSEGVTakashi Yano2-1/+3
When the thread is suspended and Rip (instruction pointer) points to an instruction that causes an exception, modifying Rip and calling ResumeThread() may sometimes result in a crash. To prevent this, advance execution by a single instruction by setting the trap flag (TF) before calling ResumeThread() as a workaround. This will trigger either STATUS_SINGLE_STEP or the exception caused by the instruction that Rip originally pointed to. By suspending the targeted thread within exception::handle(), Rip no longer points to the problematic instruction, allowing safe handling of the interrupt. As a result, Rip can be adjusted appropriately, and the thread can resume execution without unexpected crashes. Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258153.html Fixes: 1fd5e000ace5 ("import winsup-2000-02-17 snapshot") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-06-10Cygwin: Fix compatibility with w32api headers v13Radek Bartoň1-0/+4
2025-05-03Cygwin: signal: Revive toggling incyg flag in call_signal_handler()Takashi Yano1-1/+1
The commit 68991cda8185 dropped toggling incyg flag in the function call_signal_handler(). However this seems to cause another problem that the command "stress-ng --kill 0 -t 5" sometimes leaves child processes hanging. With this patch additional mechanism to determin whether the target thread is inside cygwin1.dll has been introduced instead. This mechanism utilizes _cygtls::inside_kernel() function with additional argument to return true if the code is in the cygwin DLL even if incyg flag is not set. Fixes: 68991cda8185 ("Cygwin: signal: Do not handle signals while waiting for wakeup evt") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-04-11Cygwin: console: Fix the console states after the console is closedTakashi Yano1-1/+1
Due to a bug introduced by the commit 3312f2d21f13, when the parent process exits before the child process exits, disable_master_thread is wrongly set to true, that disables special key handling such as Ctrl-C. With this patch, the disable_master_thread is set to true if any of the following conditions is met. - The parent process is not a cygwin process. - The master process already died. - The current process is the master process. Otherwise, disable_master_thread remains false to keep special key handling enabled. Addresses: https://cygwin.com/pipermail/cygwin/2025-April/257909.html Fixed: 3312f2d21f13 ("Cygwin: console: Redesign mode set strategy on close().") Reported-by: Jeremy Drake <cygwin@jdrake.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-04-09Cygwin: termios: Implement tcflow(), tcdrain(), TCXONC, TIOCINQTakashi Yano2-3/+10
Previously, tcflow() and tcdrain() were missing from console and pty. ioctl() command: TCXONC, TIOCINQ, and TCFLSH were also missing. Due to this, "stress-ng --pty 1" failed. This patch implements them. Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-04-08Cygwin: thread: Use simple array instead of List<pthread_key>Takashi Yano1-7/+24
Previously, List<pthread_key>, which used fast_mutex, was used for accessing all the valid pthread_key. This caused a deadlock when another pthread_key_create() is called in the destructor registered by the previous pthread_key_create(). This is because the run_all_destructors() calls the desructor via keys.for_each() where both for_each() and pthread_key_create() (that calls List_insert()) attempt to acquire the lock. With this patch, use simple array of pthread_key instead and realize quasi-lock-free access to that array refering to the glibc code. Addresses: https://cygwin.com/pipermail/cygwin/2025-March/257705.html Fixes: 1a821390d11d ("fix race condition in List_insert") Reported-by: Yuyi Wang <Strawberry_Str@hotmail.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-03-31Cygwin: dll::detach: drop declaration of unimplemented methodCorinna Vinschen1-1/+0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-31Cygwin: dlfcn: add native DLLs to dll listCorinna Vinschen1-1/+3
If native DLLs are dlopen'ed, we have to keep track of the load count, so dlclose doesn't misbehave. We also have to keep track for the sake of a forked child so the handle returned by dlopen is still valid in the child. To accomplish that, add a new type DLL_NATIVE. Fixes: 82b31085f6ad ("Cygwin: dlfcn: avoid ENOENT on dlcose after dlopen(cygwin1.dll)") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-31Cygwin: exceptions: check ExceptionFlags for EXCEPTION_NONCONTINUABLECorinna Vinschen1-0/+4
So far, exception::handle returned prematurely if the value of EXCEPTION_RECORD::ExceptionFlags was non-0. Starting with Windows 11 we're getting into trouble with that, if the exception is software generated, for instance by calling "throw" in a C++ application. In that case EXCEPTION_SOFTWARE_ORIGINATE (0x80) is set in EXCEPTION_RECORD::ExceptionFlags. Change the condition for exiting prematurely to do this only if any other flag except EXCEPTION_SOFTWARE_ORIGINATE is set in EXCEPTION_RECORD::ExceptionFlags. Fixes: Silent change in Windows exception handling Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-30Cygwin: dlfcn: avoid ENOENT on dlcose after dlopen(cygwin1.dll)Corinna Vinschen1-1/+1
When dlopen'ing the Cygwin DLL, refcounting the number of dlopen calls fails because dll_list::find returns NULL if the address resolves to the Cygwin DLL. Fix this by adding a bool parameter to dll_list::find which allows find to return the dll entry for the Cygwin DLL for the sake of dlopen/dlclose/fork. Fixes: 33297d810d90 ("Cygwin: dlfcn: Fix reference counting") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-24Cygwin: ntdll.h: enum _FILE_INFORMATION_CLASS: add FileKnownFolderInformationCorinna Vinschen1-0/+1
...for completeness. Introduced with Windows Server 2022. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-21Cygwin: console: tty::restore really restores the previous modeTakashi Yano1-1/+3
Previously, tty::restore sets the console mode to a predetermined console mode that is widely common for many non-cygwin console apps. So, if a non-cygwin app that is started from cygwin process changes the console mode and executes cygwin sub-process, the console mode is changed to the predetermined mode rather than being restored the original mode that is set by the non-cygwin app. With this patch, the console mode is stored when a cygwin process is started from non-cygwin app, then tty::restore restores the previous console mode that is used by the previous non-cygwin app when the cygwin app exits. Addresses: https://github.com/msys2/msys2-runtime/issues/268 Fixes: 3312f2d21f13 ("Cygwin: console: Redesign mode set strategy on close().") Reported-by: Eu Pin Tien, Jeremy Drake <cygwin@jdrake.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-03-14Cygwin: signals: pop return address from signal stack earlierTakashi Yano1-3/+16
Commit a942476236b5 ("Cygwin: sigdelayed: pop return address from signal stack earlier") failed to take two facts into account: - _cygtls::call_signal_handler() potentially needs the return address as well, and - the signal handler may be interrupted by another signal. Revert the change in sigdelayed() and handle the signal stack manipulation in _cygtls::call_signal_handler() instead. Given we're poping the latest addresses from the signal stack early, there's no need for a big signal stack anymore. Reduce the size of the stack to 4 entries, plus one dummy entry. Move _cygtls::pop() from assembler to C++ code and make sure that stackptr neither underflows nor overflows the signal stack. Fixes: a942476236b5 ("Cygwin: sigdelayed: pop return address from signal stack earlier") Co-authored-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-04Cygwin: signal: Fix a race issue on modifying _pinfo::process_stateTakashi Yano1-3/+3
The PID_STOPPED flag in _ponfo::process_state is sometimes accidentally cleared due to a race condition when modifying it with the "|=" or "&=" operators. This patch uses InterlockedOr/And() instead to avoid the race condition. Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257473.html Fixes: 1fd5e000ace55 ("import winsup-2000-02-17 snapshot") Reported-by: Christian Franke <Christian.Franke@t-online.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-03-03Cygwin: console: Redesign mode set strategy on close().Takashi Yano1-0/+1
The required console mode for a non-cygwin process is different from that for a cygwin process. There are currently three modes: tty::cygwin, tty::native, and tty::restore. The latter two are for the non-cygwin processes. tty::restore is the mode for the non-cygwin processes that started the cygwin process, used to restore the previous behaviour. tty::native is the mode that reflects some terminfo flags. The issue below is caused because the console mode fails to be restored to the previous console mode used by cmd.exe. This patch redesigns the strategy to determine which mode should be set on console close() to fix all similar problems. Previously, the number of handle count is used to determine the appropriate console mode. However, the handle count seems uncertain for that purpose. In the new design, the relation ship between the master process and the process that is about to close the console is mainly used. This can provide more certain result than previous one. Addresses: https://github.com/microsoft/git/issues/730 Fixes: 30d266947842 ("Cygwin: console: Fix clean up conditions in close()") Reported-by: Mike Marcelais, Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-02-27Cygwin: fix gcc-15 const warningsCorinna Vinschen1-3/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-27Cygwin: fix "-Werror=overloaded-virtual" errors since gcc-13Corinna Vinschen2-12/+12
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-25Cygwin: pipe_data_available: drop special casing selectCorinna Vinschen1-1/+1
After 11a84cc757ef ("Cygwin: fix SSH hangs"), select returns writability if any number of bytes are left in the buffer. Thus, the reason for pipe_data_available() to return PIPE_BUF when called from select() is gone, and we can drop special casing select(). So together with 11a84cc757ef ("Cygwin: fix SSH hangs"), this patch essentially reverts 555afcb2f3a6 ("Cygwin: select: set pipe writable only if PIPE_BUF bytes left") Rather than reverting the flag parameter to a bool, keep a mode argument set to PDA_READ or PDA_WRITE. If we can't evaluate the number of bytes left, just return 1 to select(), as for any other caller. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-19Cygwin: skip floppy drives in cygdrive_getmntent.Jeremy Drake via Cygwin-patches1-1/+7
This was previously done, but was lost when the function was updated to list all Windows mount points, not just drive letters. Fixes: 04a5b072940cc ("Cygwin: expose all windows volume mount points.") Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-13Cygwin: expose all windows volume mount points.Jeremy Drake via Cygwin-patches2-4/+7
They are exposed via the getmntent API and proc filesystem entries dealing with mounts. This allows things like `df` to show volumes that are only mounted on directories, not on drive letters. Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257251.html Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-02-13Cygwin: store list of mounts for volumes in dos_drive_mappings.Jeremy Drake via Cygwin-patches1-4/+7
The existing code only stored the first mount for each volume, but now we store the complete list, and split it into a linked list. This will be used in a subsequent commit to populate cygdrive mount entries. Signed-off-by: Jeremy Drake <cygwin@jdrake.com>
2025-01-28Cygwin: implement posix_closeCorinna Vinschen1-26/+26
per https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html Add a flag value to fhandler_*::close() and close_with_arch() methods, taking -1 as default argument, used to indicate default close(2) behaviour. The only fhandlers capable of returning EINTR are the INET based socket fhandlers. Handle -1 and POSIX_CLOSE_RESTART equivalent, making close() and posix_close(POSIX_CLOSE_RESTART) behaving identically. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-28Cygwin: fhandler: move "isclosed" status flag into fhandler_pipe_fifoCorinna Vinschen1-3/+10
The isclosed flag is only used in pipe and FIFO code, so move the flag down into the fhandler_pipe_fifo class. Note that such a flag is not sufficient to avoid evil, like closing an already closing fhandler from another thread. If we ever need this, it has to be implemented threadsafe. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-27Cygwin: message queues are not devicesCorinna Vinschen2-3/+3
Message queues are basically just files and in most cases can be handled like normal files. So it was a mistake to set the "on-disk-device" flag for them to fix the mq_unlink() problem reported in https://cygwin.com/pipermail/cygwin/2025-January/257119.html Rather, given that unlink() just checks if the object to be deleted has an on-disk representation, make sure message queues are added to the path_conv::isondisk() predicate. This also reverts commit d870655f570f25393dcefbaf0b1dc807f277749c. Fixes: d870655f570f ("Cygwin: path_conv: set on-disk-device flag for message queue files") Reported-by: Christian Franke <Christian.Franke@t-online.de> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-22Cygwin: signal: Avoid frequent TLS lock/unlock for SIGCONT processingTakashi Yano1-2/+2
It seems that current _cygtls::handle_SIGCONT() code sometimes falls into a deadlock due to frequent TLS lock/unlock operation in the yield() loop. With this patch, the yield() in the wait loop is placed outside the TLS lock to avoid frequent TLS lock/unlock. Fixes: 9ae51bcc51a7 ("Cygwin: signal: Fix another deadlock between main and sig thread") Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-01-21Cygwin: path_conv: simplify, rearrange, rename combined device checksCorinna Vinschen1-7/+19
Some checks in path_conv are checking for various properties to generate a boolean value, mostly to indicate different combinations of on-disk files and devices. Simplify these checks and, especially, document them inline. Drop the isdevice() check in favor of a new isondisk() check. Fixes: 4fc922b2c8a5 ("Cygwin: POSIX msg queues: Convert mqd_t to a descriptor") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-21Cygwin: cygwait: Make cygwait() reentrantTakashi Yano1-1/+2
To allow cygwait() to be called in the signal handler, a locally created timer is used instead of _cygtls::locals.cw_timer if it is in use. Co-Authored-By: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-01-15Cygwin: security.h: De-inline cygpsid::debug_printCorinna Vinschen1-5/+1
This allows to use the function from GDB during debugging. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-01-09Cygwin: remove winsup/cygwin/local_includes/mmap_helper.hKen Brown1-89/+0
None of its macros and functions are used anymore. Signed-off-by: Ken Brown <kbrown@cornell.edu>
2025-01-09Cygwin: mmap: remove is_mmapped_region()Ken Brown1-1/+0
The last use was removed in commit 29a126322783 ("Simplify stack allocation code in child after fork"). Signed-off-by: Ken Brown <kbrown@cornell.edu>
2024-12-19Cygwin: pinfo: raise MAX_PID to 4194304Corinna Vinschen1-1/+1
Reportedly, the maximum pid of 65536 is much too small in bigger environments. Raise the maximum PID to 4194304, whihc is the maximum pid on Linux (PID_MAX_LIMIT defined in include/linux/threads.h). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-17Cygwin: /proc/<PID>/stat: set field (18) according to scheduling policyChristian Franke1-0/+2
If a realtime policy is selected, set the '(18) priority' field to the negated sched_priority minus one. If SCHED_IDLE is selected, set it to the lowest priority 39. Also set '(19) nice' to the originally requested nice value. Ensure consistence with the current Windows priority in all cases. Move the sched_priority from/to Windows priority mapping from sched_get/setparam() to new functions in miscfuncs.cc. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-12Cygwin: sched_setscheduler: accept SCHED_RESET_ON_FORK flagChristian Franke1-2/+3
Add SCHED_RESET_ON_FORK to <sys/sched.h>. If this flag is set, SCHED_FIFO and SCHED_RR are reset to SCHED_OTHER and negative nice values are reset to zero in each child process created with fork(2). Signed-off-by: Christian Franke <christian.franke@t-online.de>