aboutsummaryrefslogtreecommitdiff
path: root/winsup
AgeCommit message (Collapse)AuthorFilesLines
2024-02-03Cygwin: document new winjitdebug optionCorinna Vinschen2-2/+18
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03Cygwin: reorder list of CYGWIN env var options alphabetically againCorinna Vinschen1-2/+2
This has been turned upside down for a short while. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03Cygwin: Do not show Error dialogs by defaultJohannes Schindelin3-1/+3
...in a non-Cygwin child process. Backported from MSYS2. Downstream commit message follows. In https://github.com/msys2/msys2-runtime/pull/18, we discussed a change that would allow default Windows error handling of spawned processes to kick in (such as registered JIT debuggers). We even agreed that it would make sense to hide this functionality behind a flag, `winjitdebug`. However, when this got upstreamed as 21ec498d7f (cygwin: use CREATE_DEFAULT_ERROR_MODE in spawn, 2020-12-09), that flag was deemed unnecessary. But it would appear that it _is_ necessary: As reported in https://github.com/msys2/MSYS2-packages/pull/2414#issuecomment-810841296 this new behavior is pretty disruptive e.g. in CI scenarios. So let's introduce that `winjitdebug` flag (settable via the environment variable `MSYS`) at long last. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03Cygwin: net: Make if_nametoindex, etc. consistent with if_nameindex.Takashi Yano3-4/+32
Currently, if_nametoindex() and if_indextoname() handle interface names such as "ethernet_32777", while if_nameindex() returns the names such as "{5AF7ACD0-D52E-4DFC-A4D0-54D3E6D6B2AC}". This patch unifies the interface names to the latter. Fixes: c356901f0d69 ("Rename if_indextoname to cygwin_if_indextoname (analag for if_nametoindex)") Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-03Cygwin: Document recent bug fix in release note.Takashi Yano1-0/+5
2024-02-03Cygwin: console: Avoid slipping past disable_master_thread check.Takashi Yano1-2/+6
If disable_master_thread flag is set between the code checking that flag not be set and the code acquiring input_mutex, input record is processed once after setting disable_master_thread flag. This patch prevents that. Fixes: d4aacd50e6cf ("Cygwin: console: Add missing input_mutex guard.") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-02Cygwin: console: Fix exit code for non-cygwin process.Takashi Yano1-3/+3
If non-cygwin process is executed in console, the exit code is not set correctly. This is because the stub process for non-cygwin app crashes in fhandler_console::set_disable_master_thread() due to NULL pointer dereference. This bug was introduced by the commit: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals."), that the pointer cons is accessed before fixing when it is NULL. This patch fixes the issue. Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals.") Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-01bump DLL version to 3.5.1Corinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29Cygwin: machine/_arc4random.h: Fix copy/paste bugCorinna Vinschen1-1/+0
Remove a stray __END_DECLS. It didn't hurt in the only (plain C) file including this header, but still... Fixes: 030a762535c1 ("Cygwin: fix arc4random after fork(2)") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29Cygwin: fix arc4random after fork(2)Corinna Vinschen2-0/+17
After using fork(), arc4random does not reseed itself, which causes the results to become predictable. Activate droppingfork-recognition Fixes: e0fc33322d50 ("Delete Cygwin's arc4random in favor of new Newlib implementation") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29Cygwin: redefine how to recognize forkee stateCorinna Vinschen5-16/+27
So far the global variable in_forkee only indicated if the process is the child process during fork(2) itself. However, we need an indicator accessible from plain C code in newlib, allowing to check for a process being a forked process all the time, after fork(2) succeeded. Redefine bool in_forkee to int __in_forkee to allow exposing it to newlib. Redefine how it indicates fork state (not forked, forking, forked). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-25Cygwin: Add a timeout to ensure we don't wait forever for dumperJon Turney1-2/+6
2024-01-24Cygwin: pthread: Fix handle leak in pthread_once.Takashi Yano1-0/+3
If pthread_once() is called with pthread_once_t initialized using PTREAD_ONCE_INIT, pthread_once does not release pthread_mutex used internally. This patch fixes that by calling pthread_mutex_destroy() in the thread which has called init_routine. Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-01-23Cygwin: Don't terminate via dumperJon Turney2-4/+9
A process which is exiting due to a core dumping signal doesn't propagate the correct exist status after dumping core, because 'dumper' itself forcibly terminates the process. Use 'dumper -n' to avoid killing the dumped process, so we continue to the end of signal_exit(), to exit with the 128+signal exit status. Busy-wait in exec_prepared_command() in an attempt to reliably notice the dumper attaching, so we don't get stuck there. Also: document these important facts for custom uses of error_start.
2024-01-23Cygwin: seekdir: don't set errnoCorinna Vinschen1-1/+0
Commit 3f3bd1010455 ("* Throughout, use __try/__except/__endtry blocks [...]") introduced setting EINVAL, marked as "Diagnosis". The reason for this is lost in time and space, but looks very much like a debug helper which was supposed to be removed before release. It's rather pointless, so remove it. Fixes: 3f3bd1010455 ("* Throughout, use __try/__except/__endtry blocks [...]") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-19Cygwin: remove warnings from testsuite buildCorinna Vinschen3-8/+4
- drop unused variable - remove deprectated usage of std::pointer_to_unary_function. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-18Cygwin: replace all `fgrep' with `grep -F'Corinna Vinschen5-8/+8
Unfortunately fgrep is now deprecated in a very pushy way. Make sure to use grep -F instead all around, even in docs and comments/ Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-17Cygwin: copy doc changes from commit 241b50a7abe2 to release notesCorinna Vinschen1-4/+4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-16Cygwin: Update documentation for cygwin_stackdumpJon Turney1-0/+4
2024-01-16Cygwin: Treat api_fatal() similarly to a core-dumping signalJon Turney3-5/+20
Provide the same debugging opportunities for api_fatal() as we do for a core-dumping signal: 1) Break into any attached debugger 2) Start JIT debugger (if configured) (keeping these under DEBUGGING doesn't seem helpful) 3) Write a coredump (if rlim_core > 1MB) 4) Write a stackdump (if that failed, or 0 < rlim_core <= 1MB)
2024-01-16Cygwin: Define and use __WCOREFLAGJon Turney2-3/+4
Also fix a typo in description of exit status
2024-01-16Cygwin: Disable writing core dumps by default.Jon Turney3-1/+10
Change the default core limit from unlimited to 0 (disabled)
2024-01-16Cygwin: Make 'ulimit -c' control writing a coredumpJon Turney7-41/+143
Pre-format a command to be executed on a fatal error to run 'dumper' (using an absolute path). Factor out executing a pre-formatted command, so we can use that for invoking the JIT debugger in try_to_debug() (if error_start is present in the CYGWIN env var) and to invoke dumper when a fatal error occurs. On a fatal error, if the core file size limit is greater than 1MB, invoke dumper to write a core dump. Otherwise, if that limit is greater than 0, write a .stackdump file, as previously. Adjust and clarify the associated documentation. Also: Fix so that the error_start JIT debugger is now invoked, even when ulimit -c is zero. Also: Fix uses of console_printf() inside exec_prepared_command(). It's output is written via the Windows console device, so needs to use Windows-style line endings. Also: consistently return non-zero from try_to_debug() if we debugged. Future work: Truncate or remove the file written, if it exceeds the maximum size set by the ulimit. Future work: Using the words "fatal error" could probably be improved on. This means exiting on one of the "certain signals whose default action is to cause the process to terminate and produce a core dump file".
2024-01-15Cygwin: introduce close_range(2)Christian Franke6-1/+56
This function closes or sets the close-on-exec flag for a specified range of file descriptors. It is available on FreeBSD and Linux. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-15Cygwin: api docs: add missing fallocateCorinna Vinschen1-0/+9
Also add notes in terms of fallocate quirks. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-12Cygwin: Clarifications in 3.5 changes docJon Turney1-4/+4
2024-01-11Cygwin: path.cc: fix comment starting with // but ending in */Corinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-10Cygwin: Fix a stray '\n' in cygcheck manpageJon Turney1-1/+1
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2024-01-08Cygwin: check remote drives for being SSDs as wellCorinna Vinschen1-1/+1
This enables automatic sparse file support for remote SSDs. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05Cygwin: fallocate(2): fix debug outputCorinna Vinschen1-1/+1
Fixes: e01c50c7b0a6 ("Cygwin: introduce fallocate(2)") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05Cygwin: fallocate(2): fix offset and length sanity checkCorinna Vinschen1-1/+3
- len must not be <= 0 - offset + len must not exceed off_t (max. file size) Fixes: e01c50c7b0a6 ("Cygwin: introduce fallocate(2)") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-05Cygwin: posix_fallocate(3): fix offset and length sanity checkCorinna Vinschen1-1/+3
- len must not be <= 0 - offset + len must not exceed off_t (max. file size) Fixes: 7636b5859062 ("* autoload.cc (NtSetInformationFile): Define.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-04Cygwin: fallocate(2): drop useless zeroing pointerCorinna Vinschen1-3/+1
The out pointer is only used if data_chunk_count is > 0, so there's no reason to set it to NULL in the error case. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-12-01Cygwin: drop stray fs_info::check_ssd declarationCorinna Vinschen1-2/+0
This is just a leftover from development Fixes: 8b01c5d6903f ("Cygwin: fs_info: check for SSD") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: doc: add missing change to posix_spawnpCorinna Vinschen1-0/+6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: sparse support: enable automatic sparsifying of files on SSDsCorinna Vinschen4-2/+11
Given that SSDs don't have a seek penalty, we can enable automatic sparsifying of files on SSDs, even if the "sparse" mount option is not set. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: fs_info: check for SSDCorinna Vinschen2-0/+18
During fs_info::update, check for the file being on an SSD. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: ntdll.h: add missing NtQueryVolumeInformationFile definitionsCorinna Vinschen1-0/+27
In preparation of using the FileFsSectorSizeInformation info class, add a couple of missing definitions. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: ntdll.h: add missing POBJECT_NAME_INFORMATIONCorinna Vinschen1-1/+1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-30Cygwin: revert autoloading of DiscardVirtualMemoryCorinna Vinschen1-0/+1
Commit a3ae2a734892 ("Cygwin: don't autoload some kernel32 functions") erroneously removed DiscardVirtualMemory from the list of autloaded functions. DiscardVirtualMemory is not available on Windows 8.1. Fixes: a3ae2a734892 ("Cygwin: don't autoload some kernel32 functions") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-29Cygwin: Add '--names-only' flag to cygcheckJon Turney3-15/+31
Add '--names-only' flag to cygcheck, to output just the bare package names.
2023-11-28Cygwin: fallocate(2): handle FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGECorinna Vinschen5-68/+302
Split fhandler_disk_file::fallocate into multiple methods, each implementing a different aspect of fallocate(2), thus adding FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE handling. For more correctly implementing posix_fallocate(3) semantics, make sure to re-allocate holes in the given range if the file is sparse. While at it, change the way checking when to make a file sparse. The rule is now, make file sparse if the hole created by the action spans at least one sparse block, taking the allocation granularity of sparse files into account. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: pwrite(2): sparsify fileCorinna Vinschen1-0/+20
write(2) sparsifies a file after an lseek far enough beyond EOF. Let pwrite(2) sparsify as well if offset is far enough beyond EOF. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: fallocate(2): fix evaluating return valueCorinna Vinschen1-1/+6
fallocate is not supposed to return an errno code, it has to return -1 and set errno. Fixes: dd90ede40510 ("Cygwin: introduce fallocate(2)") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: open(2): reset sparseness on O_TRUNCated filesCorinna Vinschen2-0/+12
open(2) implements O_TRUNC by just reducing the size of the file to 0, to make sure EAs stay available. Turns out, file sparseness is not removed this way either, so add code to do just that. Fixes: 603ef545bdbd ("* fhandler.cc (fhandler_base::open): Never open files with FILE_OVERWITE/FILE_OVERWRITE_IF.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: introduce fallocate(2)Corinna Vinschen7-7/+92
First cut of the new, Linux-specific fallocate(2) function. Do not add any functionality yet, except of basic handling of FALLOC_FL_KEEP_SIZE. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: fcntl.h: Use cdefs.h macrosCorinna Vinschen1-6/+5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: fhandler: rename ftruncate method to fallocateCorinna Vinschen6-16/+21
also, take mode flags parameter instead of just a bool. Introduce __FALLOC_FL_TRUNCATE mode flag as internal flag to indictae being called from ftruncate(2). This is in preparation of an upcoming change introducing the Linx-specific fallocate(2) call. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-28Cygwin: posix_fallocate: return ENODEVCorinna Vinschen3-1/+8
The fhandler method ftruncate returns either EISDIR if it has been called on directories, or EINVAL if called on files other than regular files. This matches what ftruncate(2) is supposed to return, but it doesn't match posix_fallocate(3), which is supposed to return ENODEV in both cases. To accomplish that, return ENODEV from fhandler_base::ftruncate() and convert it to EINVAL in ftruncate(2). In posix_fallocate(3), convert EISDIR to ENODEV. Fixes: 7636b58590621 ("* autoload.cc (NtSetInformationFile): Define.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-11-25Cygwin: lseek: check for file sparseness, not for mount point sparsenessCorinna Vinschen1-1/+1
The code introducing the lseek(2) code for the GNU extensions SEEK_DATA and SEEK_HOLE accidentally checks if the mount point has the "sparse" flag set and, if not, emulates SEEK_DATA/SEEK_HOLE per the Linux specs. However, the mount point "sparse" flag only determines whether files should be made sparse or not. Files may be sparse independently of that, obviously. Fix that by checking for the FILE_ATTRIBUTE_SPARSE_FILE attribute instead. Fixes: edfa581d3c5a ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>