stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: [patch] exec utility child process limits (unix)
Date Fri, 25 Aug 2006 23:25:07 GMT
Andrew Black wrote:
> Greetings all.
> 
> Attached is a patch that enables the exec utility to place limits on its 
> child process, using the setrlimit() command.  These changes are based 
> on the _rw_setopt_ulimit function in tests/src/driver.cpp.  It should be 
> noted that the sys/resource.h header is an XSI extension to the POSIX 
> standard, so it may not be possible to rely on this header being 
> present, though an assumption to this effect is made in this patch and 
> in tests/src/driver.cpp.

I think either _XOPEN_UNIX or _XOPEN_VERSION is the macro to check
(after #including <unistd.h>) in order to determine XSI conformance.
I.e., this would be the magic chant:

   #include <unistd.h>

   #if defined (_XOPEN_UNIX)
       /* XSI extensions supported */
   #  include <sys/resource.h>
   #endif   /* _XOPEN_UNIX */

http://www.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html

As for the patch, I'm not sure that recognizing command line options
only when they are implemented or supported is the best approach. The
utility contains the (possibly complex) logic to determine whether it
is or isn't possible to provide the feature so avoiding failures due
to it being invoked with the unimplemented option will basically mean
duplicating the same logic in the caller.

I think handling the unavailability of the options the same was as
the failure to set the limit (i.e., warning and proceeding) would
be more robust. After all, on platforms where there is no way to set
the resource limit we will still want to be able to run our tests.

Martin

Mime
View raw message