Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package cpulimit for openSUSE:Factory 
checked in at 2024-05-22 21:34:39
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cpulimit (Old)
 and      /work/SRC/openSUSE:Factory/.cpulimit.new.1880 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cpulimit"

Wed May 22 21:34:39 2024 rev:9 rq:1175912 version:3.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/cpulimit/cpulimit.changes        2024-02-21 
18:02:22.448237335 +0100
+++ /work/SRC/openSUSE:Factory/.cpulimit.new.1880/cpulimit.changes      
2024-05-22 21:35:32.644709881 +0200
@@ -1,0 +2,9 @@
+Mon May 20 13:10:29 UTC 2024 - Andrea Manzini <andrea.manz...@suse.com>
+
+- update to 3.1:
+  * The new version fixes an issue with monitoring a target process which 
+    has multiple children and a low CPU limit throttle. In some cases this 
+    situation could lead to LimitCPU crashing. This has been fixed and the
+    monitoring of children processes has been made slightly more efficient.
+
+-------------------------------------------------------------------

Old:
----
  cpulimit-3.0.tar.gz

New:
----
  cpulimit-3.1.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ cpulimit.spec ++++++
--- /var/tmp/diff_new_pack.Zrg7VB/_old  2024-05-22 21:35:33.416738118 +0200
+++ /var/tmp/diff_new_pack.Zrg7VB/_new  2024-05-22 21:35:33.416738118 +0200
@@ -18,7 +18,7 @@
 
 
 Name:           cpulimit
-Version:        3.0
+Version:        3.1
 Release:        0
 Summary:        Limit the CPU Usage of a Process
 License:        GPL-2.0-or-later

++++++ cpulimit-2.2-do_not_forget_version.patch ++++++
--- /var/tmp/diff_new_pack.Zrg7VB/_old  2024-05-22 21:35:33.436738849 +0200
+++ /var/tmp/diff_new_pack.Zrg7VB/_new  2024-05-22 21:35:33.440738996 +0200
@@ -1,7 +1,7 @@
-Index: cpulimit-2.8/cpulimit.c
+Index: cpulimit-3.1/cpulimit.c
 ===================================================================
---- cpulimit-2.8.orig/cpulimit.c
-+++ cpulimit-2.8/cpulimit.c
+--- cpulimit-3.1.orig/cpulimit.c
++++ cpulimit-3.1/cpulimit.c
 @@ -88,7 +88,7 @@
  #endif
  

++++++ cpulimit-3.0.tar.gz -> cpulimit-3.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cpulimit-3.0/CHANGELOG new/cpulimit-3.1/CHANGELOG
--- old/cpulimit-3.0/CHANGELOG  2023-04-03 15:58:14.000000000 +0200
+++ new/cpulimit-3.1/CHANGELOG  2024-05-15 17:19:39.000000000 +0200
@@ -1,3 +1,15 @@
+========== Changes in 3.1 ================
+
+Fixed an issue where cpulimit could crash when monitoring
+a process which forked more child processes while the target CPU limit
+was very low.
+Thanks to kolAflash for pointing out this problem and providing detailed
+troubleshooting.
+
+Made monitoring and creating new monitors for the children of target
+processes slightly more efficient.
+
+
 ========== Changes in 3.0 ================
 
 cpulimit could be run in an environment where it is not in the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cpulimit-3.0/Makefile new/cpulimit-3.1/Makefile
--- old/cpulimit-3.0/Makefile   2023-04-03 15:49:52.000000000 +0200
+++ new/cpulimit-3.1/Makefile   2024-05-15 17:16:59.000000000 +0200
@@ -1,4 +1,4 @@
-VERSION?=3.0
+VERSION?=3.1
 PREFIX?=/usr
 CFLAGS?=-Wall -O2
 CC?=clang
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cpulimit-3.0/cpulimit.c new/cpulimit-3.1/cpulimit.c
--- old/cpulimit-3.0/cpulimit.c 2023-04-03 15:53:52.000000000 +0200
+++ new/cpulimit-3.1/cpulimit.c 2024-05-15 15:47:57.000000000 +0200
@@ -125,7 +125,7 @@
 
 
 //return ta-tb in microseconds (no overflow checks!)
-inline long timediff(const struct timespec *ta,const struct timespec *tb) {
+long timediff(const struct timespec *ta,const struct timespec *tb) {
     unsigned long us = (ta->tv_sec-tb->tv_sec)*1000000 + (ta->tv_nsec/1000 - 
tb->tv_nsec/1000);
     return us;
 }
@@ -376,7 +376,7 @@
    caught_child = waitpid(-1, NULL, WNOHANG);
    if (verbose)
    {
-      printf("Caught child process: %d\n", (int) caught_child);
+      printf("Caught child process: %ld\n", (long int) caught_child);
       printf("%d\n", errno);
    }
    // If this was the one process we were watching, we can quit now.
@@ -601,6 +601,8 @@
     {
         if (current->child == old_pid)
         {
+           current->monitor = 0;
+           current->child = 0;
            if (previous)
                previous->next = current->next;
            else
@@ -671,10 +673,11 @@
     char line[256];
     pid_t new_ppid;
     int current_pid;
+    CHILD *my_children = NULL;
 
     proc = opendir("/proc");
     if (! proc)
-       return all_children;
+       return NULL;
 
     proc_entry = readdir(proc);
     while (proc_entry)
@@ -694,7 +697,7 @@
                  {
                      sscanf(proc_entry->d_name, "%d", &current_pid);
                      if (! Find_Child(all_children, current_pid) )
-                        all_children = Add_Child(all_children, current_pid);
+                        my_children = Add_Child(all_children, current_pid);
                  }
                  found = TRUE;
              }
@@ -707,7 +710,7 @@
         proc_entry = readdir(proc);
     }   // done reading proc file system
     closedir(proc);
-    return all_children;
+    return my_children;
 }
 
 
@@ -734,33 +737,33 @@
       while (current)
       {
          // First see if the child process is still running. If not,
-         // we can remote its node.
+         // we can remove its node.
          if (current->child)
          {
              char filename[PROC_FILENAME + 1];
              DIR *child_directory;
-             snprintf(filename, PROC_FILENAME, "/proc/%d", current->child);
+             snprintf(filename, PROC_FILENAME, "/proc/%ld", (long int) 
current->child);
              child_directory = opendir(filename);
              if (child_directory)
                 closedir(child_directory);
              else
              {
                 if (verbose)
-                  printf("Child process %d done, cleaning up.\n",
-                          (int) current->child);
+                  printf("Child process %ld done, cleaning up.\n",
+                          (long int) current->child);
                 all_children = Remove_Child(all_children, current->child);
              }
          }  // end of clean up children processes no longer running
 
          // The child process is still running, but it might not have
          // a monitor. Create a new monitoring process.
-         if ( (current->child) && (! current->monitor) )
+         else if ( (current->child) && (! current->monitor) )
          {
               pid_t returned_pid;
 
               if (verbose)
-                 printf("Creating monitoring process for %d\n",
-                        (int) current->child);
+                 printf("Creating monitoring process for %ld\n",
+                        (long int) current->child);
 
               returned_pid = fork();
               if (returned_pid > 0)
@@ -774,7 +777,7 @@
                  char limit_amount[16];
                  char process_identifier[16];
                  snprintf(limit_amount, 16, "%d", (int) program_data->limit);
-                 snprintf(process_identifier, 16, "%d", current->child);
+                 snprintf(process_identifier, 16, "%ld", (long int) 
current->child);
                  if (verbose)
                     printf("Starting monitor with: %s -l %s -p %s -z -m\n",
                             program_data->this_program, limit_amount,
@@ -790,10 +793,10 @@
               }
               
          }    // end of creating a new monitor
-         if (verbose)
+         if ( (verbose) && (! quitting) )
          {
-             printf("Watching child: %d with %d\n", 
-                   (int) current->child, (int) current->monitor);
+             printf("Watching child: %ld with %ld\n", 
+                   (long int) current->child, (long int) current->monitor);
          }
          current = current->next;
       }
@@ -1083,7 +1086,7 @@
                     lazy = TRUE;
                     pid_ok = TRUE;
                     if (verbose)
-                      printf("Throttling process %d\n", (int) pid);
+                      printf("Throttling process %ld\n", (long int) pid);
                  }
                  else    // parent cpulimit process which can quit
                    exit(0);

Reply via email to