+Thu Jan 5 9:33:00 2001 Corinna Vinschen <corina@vinschen.de>
+
+ * resource.cc (getrlimit): Set errno on EFAULT instead of returning
+ it.
+ (setrlimit): Ditto.
+
+Thu Jan 5 3:38:00 2001 David Sainty <David.Sainty@optimation.co.nz>
+
+ * resource.cc (setrlimit): Prevent failing with an error when the
+ operation would not have changed anything.
+
Thu Jan 4 10:29:54 2001 Earnie Boyd <earnie_boyd@yahoo.com>
* thread.cc: Need LONG_MAX definition.
/* resource.cc: getrusage () and friends.
- Copyright 1996, 1997, 1998, 2000 Cygnus Solutions.
+ Copyright 1996, 1997, 1998, 2000, 2001 Cygnus Solutions.
Written by Steve Chamberlain (sac@cygnus.com), Doug Evans (dje@cygnus.com),
Geoffrey Noer (noer@cygnus.com) of Cygnus Support.
{
MEMORY_BASIC_INFORMATION m;
if (!rlp || !VirtualQuery (rlp, &m, sizeof (m)) || (m.State != MEM_COMMIT))
- return EFAULT;
+ {
+ set_errno (EFAULT);
+ return -1;
+ }
rlp->rlim_cur = RLIM_INFINITY;
rlp->rlim_max = RLIM_INFINITY;
{
MEMORY_BASIC_INFORMATION m;
if (!rlp || !VirtualQuery (rlp, &m, sizeof (m)) || (m.State != MEM_COMMIT))
- return EFAULT;
+ {
+ set_errno (EFAULT);
+ return -1;
+ }
+
+ struct rlimit oldlimits;
+
+ // Check if the request is to actually change the resource settings.
+ // If it does not result in a change, take no action and do not
+ // fail.
+ if (getrlimit(resource, &oldlimits) < 0)
+ return -1;
+
+ if (oldlimits.rlim_cur == rlp->rlim_cur &&
+ oldlimits.rlim_max == rlp->rlim_max)
+ // No change in resource requirements, succeed immediately
+ return 0;
switch (resource)
{