stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Black <>
Subject [patch] exec utility child process limits (unix)
Date Tue, 22 Aug 2006 21:28:49 GMT
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.

	* cmdopt.h [!_WIN32 && !_WIN64]: Include sys/resource.h.
	  [!_WIN32 && !_WIN64 && (RLIMIT_CORE || RLIMIT_CPU || RLIMIT_DATA)]: 
Define HAS_RLIMIT, define struct limit_set, declare child_limits.
	* cmdopt.c [!_WIN32 && !_WIN64]: Include sys/resource.h, define 
RLIM_SAVED_CUR and RLIM_SAVED_MAX if not defined.
	  [HAS_RLIMIT]: Initialize child_limits.
	  usage_text[] [HAS_RLIMIT]: Document --ulimit switch.
	  [HAS_RLIMIT] parse_limit_opts: Define helper function for parsing 
--rlimit option (borrowed in part from _rw_setopt_ulimit in 
	  eval_options() [HAS_RLIMIT]: Define opt_ulimit character string, use 
with parse_limit_opts to handle --ulimit command line switch.
	* exec.cpp [!_WIN32 && !_WIN64 && HAS_RLIMIT] LIMIT: Define helper 
macro for...
	  [!_WIN32 && !_WIN64 && HAS_RLIMIT] limit_process(): New helper 
function to set resource limits, based on the values in child_limits 
(borrowed in part from _rw_setopt_ulimit in tests/src/driver.cpp).
	  [!_WIN32 && !_WIN64 && HAS_RLIMIT] exec_file(): Call above prior to 

View raw message