~ubuntu-branches/ubuntu/lucid/python2.6/lucid

« back to all changes in this revision

Viewing changes to Modules/resource.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-10-03 12:03:05 UTC
  • mto: (10.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20091003120305-hij6yssh0figh590
Tags: upstream-2.6.3
ImportĀ upstreamĀ versionĀ 2.6.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
147
147
        int resource;
148
148
        PyObject *curobj, *maxobj;
149
149
 
150
 
        if (!PyArg_ParseTuple(args, "i(OO):setrlimit", 
 
150
        if (!PyArg_ParseTuple(args, "i(OO):setrlimit",
151
151
                              &resource, &curobj, &maxobj))
152
152
                return NULL;
153
153
 
159
159
 
160
160
#if !defined(HAVE_LARGEFILE_SUPPORT)
161
161
        rl.rlim_cur = PyInt_AsLong(curobj);
162
 
        if (rl.rlim_cur == -1 && PyErr_Occurred())
 
162
        if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred())
163
163
            return NULL;
164
164
        rl.rlim_max = PyInt_AsLong(maxobj);
165
 
        if (rl.rlim_max == -1 && PyErr_Occurred())
 
165
        if (rl.rlim_max == (rlim_t)-1 && PyErr_Occurred())
166
166
            return NULL;
167
167
#else
168
168
        /* The limits are probably bigger than a long */
169
169
        rl.rlim_cur = PyLong_Check(curobj) ?
170
170
                PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj);
171
 
        if (rl.rlim_cur == -1 && PyErr_Occurred())
 
171
        if (rl.rlim_cur == (rlim_t)-1 && PyErr_Occurred())
172
172
            return NULL;
173
173
        rl.rlim_max = PyLong_Check(maxobj) ?
174
174
                PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj);
175
 
        if (rl.rlim_max == -1 && PyErr_Occurred())
 
175
        if (rl.rlim_max == (rlim_t)-1 && PyErr_Occurred())
176
176
            return NULL;
177
177
#endif
178
178
 
179
179
        rl.rlim_cur = rl.rlim_cur & RLIM_INFINITY;
180
180
        rl.rlim_max = rl.rlim_max & RLIM_INFINITY;
181
181
        if (setrlimit(resource, &rl) == -1) {
182
 
                if (errno == EINVAL) 
 
182
                if (errno == EINVAL)
183
183
                        PyErr_SetString(PyExc_ValueError,
184
184
                                        "current limit exceeds maximum limit");
185
185
                else if (errno == EPERM)