python/psutil/psutil/_psutil_common.c

branch
TOR_BUG_9701
changeset 12
7540298fafa1
equal deleted inserted replaced
-1:000000000000 0:7b0980abb832
1 /*
2 * Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 *
6 * Routines common to all platforms.
7 */
8
9 #include <Python.h>
10
11
12 /*
13 * Set OSError(errno=ESRCH, strerror="No such process") Python exception.
14 */
15 PyObject *
16 NoSuchProcess(void) {
17 PyObject *exc;
18 char *msg = strerror(ESRCH);
19 exc = PyObject_CallFunction(PyExc_OSError, "(is)", ESRCH, msg);
20 PyErr_SetObject(PyExc_OSError, exc);
21 Py_XDECREF(exc);
22 return NULL;
23 }
24
25 /*
26 * Set OSError(errno=EACCES, strerror="Permission denied") Python exception.
27 */
28 PyObject *
29 AccessDenied(void) {
30 PyObject *exc;
31 char *msg = strerror(EACCES);
32 exc = PyObject_CallFunction(PyExc_OSError, "(is)", EACCES, msg);
33 PyErr_SetObject(PyExc_OSError, exc);
34 Py_XDECREF(exc);
35 return NULL;
36 }

mercurial