From: Viktor Szakats Date: Thu, 20 Feb 2025 22:42:46 +0000 (+0100) Subject: tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin `MAX_PID` bump X-Git-Tag: curl-8_13_0~405 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4842f22bfa23a2304e1fd8fa04cfd8b0bd1a0a92;p=thirdparty%2Fcurl.git 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 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ab938816c1..398547adb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/acinclude.m4 b/acinclude.m4 index 9c74bea992..ab267a7a0c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 diff --git a/tests/data/test1158 b/tests/data/test1158 index f3cce4496d..34845a74f3 100644 --- a/tests/data/test1158 +++ b/tests/data/test1158 @@ -21,6 +21,7 @@ blablabla Mime +!win32 http @@ -31,9 +32,6 @@ HTTP RFC1867-type formposting with filename containing '"' 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"' - -%PERL -e "print 'Test requires a system supporting double quotes in file names' if ($^O eq 'msys');" - # We create this file before the command is invoked! foo bar diff --git a/tests/data/test1186 b/tests/data/test1186 index 5e528dc43f..dabe270968 100644 --- a/tests/data/test1186 +++ b/tests/data/test1186 @@ -21,6 +21,7 @@ blablabla Mime +!win32 http @@ -31,9 +32,6 @@ Multipart formposting with backslash-escaping filename containing '"' 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"' - -%PERL -e "print 'Test requires a system supporting double quotes in file names' if ($^O eq 'msys');" - # We create this file before the command is invoked! foo bar diff --git a/tests/dictserver.py b/tests/dictserver.py index c28a22e5bd..ad65e55957 100755 --- a/tests/dictserver.py +++ b/tests/dictserver.py @@ -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") diff --git a/tests/negtelnetserver.py b/tests/negtelnetserver.py index 2727cbd25e..e043d538e5 100755 --- a/tests/negtelnetserver.py +++ b/tests/negtelnetserver.py @@ -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: diff --git a/tests/processhelp.pm b/tests/processhelp.pm index 0a0ce1939e..0181929563 100644 --- a/tests/processhelp.pm +++ b/tests/processhelp.pm @@ -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; } diff --git a/tests/server/util.c b/tests/server/util.c index 388dab1479..57ce45b0ec 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -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; } diff --git a/tests/smbserver.py b/tests/smbserver.py index e267ffe210..d48abc6729 100755 --- a/tests/smbserver.py +++ b/tests/smbserver.py @@ -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)