]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tidy-up: align MSYS2/Cygwin codepaths, follow Cygwin `MAX_PID` bump
authorViktor Szakats <commit@vsz.me>
Thu, 20 Feb 2025 22:42:46 +0000 (23:42 +0100)
committerViktor Szakats <commit@vsz.me>
Fri, 21 Feb 2025 10:58:05 +0000 (11:58 +0100)
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

CMakeLists.txt
acinclude.m4
tests/data/test1158
tests/data/test1186
tests/dictserver.py
tests/negtelnetserver.py
tests/processhelp.pm
tests/server/util.c
tests/smbserver.py

index ab938816c1d98dc886e634dc0d62082fea573151..398547adb4262fa21ceae846894648ad03b1dd0c 100644 (file)
@@ -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()
index 9c74bea992b833cfb8cba5f6e5fb60da5dfd2197..ab267a7a0c6a13f2cc3ca5a00a9ff3136729de29 100644 (file)
@@ -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
index f3cce4496df725f868c6c55692a27cffeebb7bf9..34845a74f3153bc3bdf7853d0118d0a9942000b8 100644 (file)
@@ -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
index 5e528dc43f28a605181004283fe21b30bba7407d..dabe270968b10902fcd9f36121f6509a903342b5 100644 (file)
@@ -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
index c28a22e5bd3535379aea9604c50b54e69ffd107a..ad65e55957b01ce8599a33e305864b0ef8474b95 100755 (executable)
@@ -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")
index 2727cbd25e3209c745dc5884653a190a47eaed39..e043d538e565764a9eb8a081ec95cf772660632c 100755 (executable)
@@ -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:
index 0a0ce1939eee97704dccdf624f3700562c8987d9..01819295631488c2bab0c3fde08eb76bcfa1f9f6 100644 (file)
@@ -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;
         }
index 388dab1479bff6a6d1a8e00f6d6beff092d45180..57ce45b0ec7da762e0f03b74777a48e0f6646d15 100644 (file)
@@ -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;
 }
index e267ffe21042469ccfde373cdeca154e1f989e41..d48abc6729a4a833e09dcc24d34a9a6d9c180d81 100755 (executable)
@@ -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)