Boost logo

Boost-Commit :

From: kbelco_at_[hidden]
Date: 2007-09-16 20:27:38


Author: noel_belcourt
Date: 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
New Revision: 39334
URL: http://svn.boost.org/trac/boost/changeset/39334

Log:
Added missing #include <utility> and qualified
make_pair with std:: to library_status.cpp.

Added missing headers to make1.c and missing prototypes
to builtin.h

Modified execunix.c to add support for terminating
processes that consume too much cpu or that hang and
fail to consume cpu at all. This in support of the
bjam -lx option.

http://svn.boost.org/trac/boost/ticket/1266#comment:2

Text files modified:
   trunk/tools/build/v2/tools/pgi.jam | 4 +-
   trunk/tools/jam/src/builtins.h | 6 +++++
   trunk/tools/jam/src/execunix.c | 41 ++++++++++++++++++++++++++++++++++++++++
   trunk/tools/jam/src/make1.c | 1
   trunk/tools/regression/library_status.cpp | 13 ++++++-----
   5 files changed, 57 insertions(+), 8 deletions(-)

Modified: trunk/tools/build/v2/tools/pgi.jam
==============================================================================
--- trunk/tools/build/v2/tools/pgi.jam (original)
+++ trunk/tools/build/v2/tools/pgi.jam 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
@@ -54,7 +54,7 @@
 flags pgi.compile OPTIONS <profiling>on : -xprofile=tcov ;
 flags pgi.compile OPTIONS <optimization>speed : -fast -Mx,8,0x10000000 ;
 flags pgi.compile OPTIONS <optimization>space : -xO2 -xspace ;
-flags pgi.compile OPTIONS <threading>multi : -mt ;
+# flags pgi.compile OPTIONS <threading>multi : -mt ;
 
 flags pgi.compile OPTIONS <warnings>off : -Minform=severe ;
 flags pgi.compile OPTIONS <warnings>on : -Minform=warn ;
@@ -88,7 +88,7 @@
 # Strip the binary when no debugging is needed
 flags pgi.link OPTIONS <debug-symbols>off : -s ;
 flags pgi.link OPTIONS <profiling>on : -xprofile=tcov ;
-flags pgi.link OPTIONS <threading>multi : -mt ;
+# flags pgi.link OPTIONS <threading>multi : -mt ;
 flags pgi.link OPTIONS <linkflags> ;
 flags pgi.link LINKPATH <library-path> ;
 flags pgi.link FINDLIBS-ST <find-static-library> ;

Modified: trunk/tools/jam/src/builtins.h
==============================================================================
--- trunk/tools/jam/src/builtins.h (original)
+++ trunk/tools/jam/src/builtins.h 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
@@ -14,6 +14,12 @@
  */
 
 void load_builtins();
+void init_set();
+void init_path();
+void init_regex();
+void init_property_set();
+void init_sequence();
+void init_order();
 
 LIST *builtin_calc( PARSE *parse, FRAME *args );
 LIST *builtin_depends( PARSE *parse, FRAME *args );

Modified: trunk/tools/jam/src/execunix.c
==============================================================================
--- trunk/tools/jam/src/execunix.c (original)
+++ trunk/tools/jam/src/execunix.c 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
@@ -8,11 +8,14 @@
 # include "jam.h"
 # include "lists.h"
 # include "execcmd.h"
+# include "output.h"
 # include <errno.h>
 # include <signal.h>
 # include <stdio.h>
 # include <time.h>
 # include <unistd.h> /* needed for vfork(), _exit() prototypes */
+# include <sys/resource.h>
+# include <sys/times.h>
 
 #if defined(sun) || defined(__sun) || defined(linux)
 #include <wait.h>
@@ -68,6 +71,7 @@
     int pid; /* on win32, a real process handle */
     int fd[2]; /* file descriptors for stdout and stderr */
     FILE *stream[2]; /* child's stdout (0) and stderr (1) file stream */
+ clock_t start_time; /* start time of child process */
     int action_length; /* length of action string */
     int target_length; /* length of target string */
     char *action; /* buffer to hold action and target invoked */
@@ -194,6 +198,31 @@
             else
                 dup2(err[1], STDERR_FILENO);
 
+ /* terminate processes only if timeout is positive */
+ if (0 < globs.timeout) {
+ struct rlimit rl;
+ struct tms buf;
+
+ /*
+ * set hard and soft resource limits for cpu usage
+ * won't catch hung processes that don't consume cpu
+ */
+ rl.rlim_cur = globs.timeout;
+ rl.rlim_max = globs.timeout;
+ setrlimit(RLIMIT_CPU, &rl);
+
+ /*
+ * handle hung processes using different mechanism
+ * manually track elapsed time and signal process
+ * when time limit expires
+ *
+ * could use this approach for both consuming too
+ * much cpu and hung processes, but it never hurts
+ * to have backup
+ */
+ cmdtab[ slot ].start_time = times(&buf);
+ }
+
             execvp( argv[0], argv );
             _exit(127);
         }
@@ -339,6 +368,8 @@
     struct tms old_time, new_time;
     char *tmp;
     char buffer[BUFSIZ];
+ struct tms buf;
+ clock_t current = times(&buf);
 
     /* Handle naive make1() which doesn't know if cmds are running. */
 
@@ -358,6 +389,11 @@
             {
                 fd_max = fd_max < cmdtab[i].fd[OUT] ? cmdtab[i].fd[OUT] : fd_max;
                 FD_SET(cmdtab[i].fd[OUT], &fds);
+
+ /* signal child processes that have expired (timed out) */
+ if (cmdtab[i].start_time && globs.timeout < current - cmdtab[i].start_time) {
+ kill(cmdtab[i].pid, SIGKILL);
+ }
             }
             if (globs.pipe_action != 0)
             {
@@ -365,6 +401,11 @@
                 {
                     fd_max = fd_max < cmdtab[i].fd[ERR] ? cmdtab[i].fd[ERR] : fd_max;
                     FD_SET(cmdtab[i].fd[ERR], &fds);
+
+ /* signal child processes that have expired (timed out) */
+ if (cmdtab[i].start_time && globs.timeout < current - cmdtab[i].start_time) {
+ kill(cmdtab[i].pid, SIGKILL);
+ }
                 }
             }
         }

Modified: trunk/tools/jam/src/make1.c
==============================================================================
--- trunk/tools/jam/src/make1.c (original)
+++ trunk/tools/jam/src/make1.c 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
@@ -61,6 +61,7 @@
 # include "command.h"
 # include "execcmd.h"
 # include "compile.h"
+# include "output.h"
 
 # include <stdlib.h>
 

Modified: trunk/tools/regression/library_status.cpp
==============================================================================
--- trunk/tools/regression/library_status.cpp (original)
+++ trunk/tools/regression/library_status.cpp 2007-09-16 20:27:37 EDT (Sun, 16 Sep 2007)
@@ -44,6 +44,7 @@
 #include <ctime>
 #include <stdexcept>
 #include <cassert>
+#include <utility>
 
 using std::string;
 
@@ -295,12 +296,12 @@
         }
 
         links_file << "<h2><a name=\"";
- links_file << make_pair(
+ links_file << std::make_pair(
             html_from_path(target_dir.string().begin()),
             html_from_path(target_dir.string().end())
             )
             << "\">"
- << make_pair(
+ << std::make_pair(
             html_from_path(target_dir.string().begin()),
             html_from_path(target_dir.string().end())
             )
@@ -337,13 +338,13 @@
                 "See <a href=\"#"
                 << source_library_name << "-"
                 << object_library_name << "-"
- << make_pair(
+ << std::make_pair(
                 html_from_path(target_dir.string().begin()),
                 html_from_path(target_dir.string().end())
                 )
                 << source_library_name << " - "
                 << object_library_name << " - "
- << make_pair(
+ << std::make_pair(
                 html_from_path(target_dir.string().begin()),
                 html_from_path(target_dir.string().end())
                 )
@@ -369,13 +370,13 @@
                 {
                     links_file << "<h2><a name=\""
                         << object_library_name << "-"
- << make_pair(
+ << std::make_pair(
                         html_from_path(target_dir.string().begin()),
                         html_from_path(target_dir.string().end())
                         )
                         << "\">"
                         << object_library_name << " - "
- << make_pair(
+ << std::make_pair(
                         html_from_path(target_dir.string().begin()),
                         html_from_path(target_dir.string().end())
                         )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk