tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin MAX_PID bump
MSYS/MSYS2 and Cygwin are the same platform. Adjust code where they were treated differently. - drop separate `MSYS` from buildinfo flags. Our code is using the `CYGWIN` variable and CMake (since v3.21) sets it also for `MSYS`. - fix test1158 and test1186 to exclude them for all Win32 targets, instead of just MSYS test envs. To align behavior between MSYS and Cygwin envs. Required for recent MSYS2 releases which reports itself as Cygwin, and no longer MSYS, which broke the previous exclusion logic. - follow Cygwin bumping its `MAX_PID` value, to avoid PID collisions. https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=363357c023ce01e936bdaedf0f479292a8fa4e0f Reported-by: Jeremy Drake Bug: https://github.com/curl/curl/pull/16217#issuecomment-2672768233 Ref: https://www.msys2.org/news/#2025-02-14-moving-msys2-closer-to-cygwin Closes #16411
This commit is contained in:
parent
540d341b38
commit
4842f22bfa
@ -125,9 +125,6 @@ endif()
|
||||
if(CYGWIN)
|
||||
string(APPEND _target_flags " CYGWIN")
|
||||
endif()
|
||||
if(MSYS)
|
||||
string(APPEND _target_flags " MSYS")
|
||||
endif()
|
||||
if(DOS)
|
||||
string(APPEND _target_flags " DOS")
|
||||
endif()
|
||||
|
||||
@ -1483,7 +1483,6 @@ AC_DEFUN([CURL_PREPARE_BUILDINFO], [
|
||||
curl_pflags="${curl_pflags} CYGWIN"
|
||||
fi
|
||||
case $host_os in
|
||||
msys*) curl_pflags="${curl_pflags} MSYS";;
|
||||
msdos*) curl_pflags="${curl_pflags} DOS";;
|
||||
amiga*) curl_pflags="${curl_pflags} AMIGA";;
|
||||
esac
|
||||
|
||||
@ -21,6 +21,7 @@ blablabla
|
||||
<client>
|
||||
<features>
|
||||
Mime
|
||||
!win32
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
@ -31,9 +32,6 @@ HTTP RFC1867-type formposting with filename containing '"'
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER -F "file=@\"%LOGDIR/test%TESTNUMBER\\\".txt\";type=mo/foo;filename=\"test%TESTNUMBER\\\".txt\"" -F 'file2=@"%LOGDIR/test%TESTNUMBER\".txt"' -F 'file3=@"%LOGDIR/test%TESTNUMBER\".txt";type=m/f,"%LOGDIR/test%TESTNUMBER\".txt"'
|
||||
</command>
|
||||
<precheck>
|
||||
%PERL -e "print 'Test requires a system supporting double quotes in file names' if ($^O eq 'msys');"
|
||||
</precheck>
|
||||
# We create this file before the command is invoked!
|
||||
<file name=%LOGDIR/test%TESTNUMBER".txt>
|
||||
foo bar
|
||||
|
||||
@ -21,6 +21,7 @@ blablabla
|
||||
<client>
|
||||
<features>
|
||||
Mime
|
||||
!win32
|
||||
</features>
|
||||
<server>
|
||||
http
|
||||
@ -31,9 +32,6 @@ Multipart formposting with backslash-escaping filename containing '"'
|
||||
<command>
|
||||
http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --form-escape -F "file=@\"%LOGDIR/test%TESTNUMBER\\\".txt\";type=mo/foo;filename=\"test%TESTNUMBER\\\".txt\"" -F 'file2=@"%LOGDIR/test%TESTNUMBER\".txt"' -F 'file3=@"%LOGDIR/test%TESTNUMBER\".txt";type=m/f,"%LOGDIR/test%TESTNUMBER\".txt"'
|
||||
</command>
|
||||
<precheck>
|
||||
%PERL -e "print 'Test requires a system supporting double quotes in file names' if ($^O eq 'msys');"
|
||||
</precheck>
|
||||
# We create this file before the command is invoked!
|
||||
<file name=%LOGDIR/test%TESTNUMBER".txt>
|
||||
foo bar
|
||||
|
||||
@ -55,7 +55,7 @@ def dictserver(options):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
with open(options.pidfile, "w") as f:
|
||||
f.write(str(pid))
|
||||
|
||||
@ -90,7 +90,7 @@ class DictHandler(socketserver.BaseRequestHandler):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
response_data = VERIFIED_RSP.format(pid=pid)
|
||||
else:
|
||||
log.debug("[DICT] Received normal request")
|
||||
|
||||
@ -55,7 +55,7 @@ def telnetserver(options):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
with open(options.pidfile, "w") as f:
|
||||
f.write(str(pid))
|
||||
|
||||
@ -93,7 +93,7 @@ class NegotiatingTelnetHandler(socketserver.BaseRequestHandler):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
response = VERIFIED_RSP.format(pid=pid)
|
||||
response_data = response.encode('utf-8')
|
||||
else:
|
||||
|
||||
@ -110,8 +110,8 @@ sub pidfromfile {
|
||||
#
|
||||
sub winpid_to_pid {
|
||||
my $vpid = $_[0];
|
||||
if(($^O eq 'cygwin' || $^O eq 'msys') && $vpid > 65536) {
|
||||
my $pid = Cygwin::winpid_to_pid($vpid - 65536);
|
||||
if(($^O eq 'cygwin' || $^O eq 'msys') && $vpid > 4194304) {
|
||||
my $pid = Cygwin::winpid_to_pid($vpid - 4194304);
|
||||
if($pid) {
|
||||
return $pid;
|
||||
} else {
|
||||
@ -133,8 +133,8 @@ sub pidexists {
|
||||
if($pid > 0) {
|
||||
# verify if currently existing Windows process
|
||||
$pid = winpid_to_pid($pid);
|
||||
if ($pid > 65536 && os_is_win()) {
|
||||
$pid -= 65536;
|
||||
if ($pid > 4194304 && os_is_win()) {
|
||||
$pid -= 4194304;
|
||||
if($^O ne 'MSWin32') {
|
||||
my $filter = "PID eq $pid";
|
||||
# https://ss64.com/nt/tasklist.html
|
||||
@ -164,8 +164,8 @@ sub pidterm {
|
||||
if($pid > 0) {
|
||||
# request the process to quit
|
||||
$pid = winpid_to_pid($pid);
|
||||
if ($pid > 65536 && os_is_win()) {
|
||||
$pid -= 65536;
|
||||
if ($pid > 4194304 && os_is_win()) {
|
||||
$pid -= 4194304;
|
||||
if($^O ne 'MSWin32') {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd = "taskkill -t -pid $pid >nul 2>&1";
|
||||
@ -189,8 +189,8 @@ sub pidkill {
|
||||
if($pid > 0) {
|
||||
# request the process to quit
|
||||
$pid = winpid_to_pid($pid);
|
||||
if ($pid > 65536 && os_is_win()) {
|
||||
$pid -= 65536;
|
||||
if ($pid > 4194304 && os_is_win()) {
|
||||
$pid -= 4194304;
|
||||
if($^O ne 'MSWin32') {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd = "taskkill -f -t -pid $pid >nul 2>&1";
|
||||
@ -214,7 +214,7 @@ sub pidwait {
|
||||
|
||||
$pid = winpid_to_pid($pid);
|
||||
# check if the process exists
|
||||
if ($pid > 65536 && os_is_win()) {
|
||||
if ($pid > 4194304 && os_is_win()) {
|
||||
if($flags == &WNOHANG) {
|
||||
return pidexists($pid)?0:$pid;
|
||||
}
|
||||
|
||||
@ -284,13 +284,15 @@ curl_off_t our_getpid(void)
|
||||
|
||||
pid = (curl_off_t)Curl_getpid();
|
||||
#if defined(_WIN32)
|
||||
/* store pid + 65536 to avoid conflict with Cygwin/msys PIDs, see also:
|
||||
* - https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
* h=b5e1003722cb14235c4f166be72c09acdffc62ea
|
||||
* - https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
* h=448cf5aa4b429d5a9cebf92a0da4ab4b5b6d23fe
|
||||
/* store pid + MAX_PID to avoid conflict with Cygwin/msys PIDs, see also:
|
||||
* - 2019-01-31: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
* h=b5e1003722cb14235c4f166be72c09acdffc62ea
|
||||
* - 2019-02-02: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
* h=448cf5aa4b429d5a9cebf92a0da4ab4b5b6d23fe
|
||||
* - 2024-12-19: https://cygwin.com/git/?p=newlib-cygwin.git;a=commit; ↵
|
||||
* h=363357c023ce01e936bdaedf0f479292a8fa4e0f
|
||||
*/
|
||||
pid += 65536;
|
||||
pid += 4194304;
|
||||
#endif
|
||||
return pid;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ def smbserver(options):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
with open(options.pidfile, "w") as f:
|
||||
f.write(str(pid))
|
||||
|
||||
@ -331,7 +331,7 @@ class TestSmbServer(imp_smbserver.SMBSERVER):
|
||||
pid = os.getpid()
|
||||
# see tests/server/util.c function write_pidfile
|
||||
if os.name == "nt":
|
||||
pid += 65536
|
||||
pid += 4194304
|
||||
contents = VERIFIED_RSP.format(pid=pid).encode('utf-8')
|
||||
|
||||
self.write_to_fid(fid, contents)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user