~vcs-imports/gnome-mag/master

« back to all changes in this revision

Viewing changes to colorblind/osutils/_osutilsmodule.c

  • Committer: Carlos Eduardo Rodrigues Diógenes
  • Date: 2007-06-03 23:52:07 UTC
  • Revision ID: git-v1:42a8898cb38357218626e4c81555423da8ab37cd
Tags: GNOME_MAG_0_14_5
commit the changes of the colorblind applet

svn path=/trunk/; revision=515

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_CONFIG_H
 
2
#include <config.h>
 
3
#endif
 
4
 
 
5
#include <Python.h>
 
6
#ifdef HAVE_PRCTL
 
7
#include <sys/prctl.h>
 
8
#endif
 
9
#include <stdio.h>
 
10
#include <errno.h>
 
11
 
 
12
/* Function Prototypes */
 
13
static PyObject * osutils_set_process_name (PyObject *self, PyObject *args);
 
14
 
 
15
/* Function Mapping Table */
 
16
static PyMethodDef py_osutils_functions[] =
 
17
{
 
18
        { "set_process_name", osutils_set_process_name, METH_VARARGS, "" },
 
19
        { NULL, NULL, 0, NULL }
 
20
};
 
21
 
 
22
PyMODINIT_FUNC
 
23
init_osutils (void)
 
24
{
 
25
        Py_InitModule ("_osutils", py_osutils_functions);
 
26
}
 
27
        
 
28
static PyObject *
 
29
osutils_set_process_name (PyObject *self, PyObject *args)
 
30
{
 
31
        const char *name;
 
32
 
 
33
        if (!PyArg_ParseTuple (args, "s", &name))
 
34
        {
 
35
                PyErr_SetString (PyExc_TypeError, "set_process_name needs a string as argument");
 
36
                return NULL;
 
37
        }
 
38
 
 
39
#ifdef HAVE_PRCTL
 
40
        if (prctl (PR_SET_NAME, (unsigned long) name, 0, 0, 0))
 
41
        {
 
42
                PyErr_SetString (PyExc_IOError, "prctl() failed");
 
43
                return NULL;
 
44
        }
 
45
 
 
46
        Py_INCREF(Py_None);
 
47
        return Py_None;
 
48
#else
 
49
        PyErr_SetString (PyExc_IOError, "prctl unavailable");
 
50
        return NULL;
 
51
#endif
 
52
}