Index: configure =================================================================== --- configure (revisión: 71311) +++ configure (copia de trabajo) @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 70903 . +# From configure.in Revision: 71009 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 2.7. # @@ -5589,6 +5589,7 @@ + for ac_header in asm/types.h conio.h curses.h direct.h dlfcn.h errno.h \ fcntl.h grp.h \ ieeefp.h io.h langinfo.h libintl.h ncurses.h poll.h process.h pthread.h \ @@ -5596,7 +5597,7 @@ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ sys/lock.h sys/mkdev.h sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ +sys/param.h sys/prctl.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ Index: configure.in =================================================================== --- configure.in (revisión: 71311) +++ configure.in (copia de trabajo) @@ -1245,7 +1245,7 @@ unistd.h utime.h \ sys/audioio.h sys/bsdtty.h sys/epoll.h sys/event.h sys/file.h sys/loadavg.h \ sys/lock.h sys/mkdev.h sys/modem.h \ -sys/param.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ +sys/param.h sys/prctl.h sys/poll.h sys/select.h sys/socket.h sys/statvfs.h sys/stat.h \ sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/un.h sys/utsname.h sys/wait.h pty.h libutil.h \ sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ Index: Modules/posixmodule.c =================================================================== --- Modules/posixmodule.c (revisión: 71311) +++ Modules/posixmodule.c (copia de trabajo) @@ -96,6 +96,11 @@ #include #endif +#ifdef HAVE_SYS_PRCTL_H +#include +extern void Py_GetArgcArgv(int *argc, char ***argv); +#endif + /* Various compilers have only certain posix functions */ /* XXX Gosh I wish these were all moved into pyconfig.h */ #if defined(PYCC_VACPP) && defined(PYOS_OS2) @@ -4046,6 +4051,39 @@ #endif +#ifdef HAVE_SYS_PRCTL_H +PyDoc_STRVAR(posix_getprocname__doc__, +"getprocname() -> procname\n\nReturn the current process name"); + +static PyObject * +posix_getprocname(PyObject *self, PyObject *args) +{ + int argc; + char **argv; + Py_GetArgcArgv(&argc, &argv); + return Py_BuildValue("s", argv[0]); +} + +#ifdef PR_SET_NAME +PyDoc_STRVAR(posix_setprocname__doc__, +"setprocname(name)\n\nSet the current process name"); +static PyObject * +posix_setprocname(PyObject *self, PyObject *args) { + int argc; + char **argv; + char *name; + if (!PyArg_ParseTuple(args, "s", &name)) + return NULL; + Py_GetArgcArgv(&argc, &argv); + strncpy(argv[0], name , strlen(name)); + memset(&argv[0][strlen(name)], '\0', strlen(&argv[0][strlen(name)])); + prctl (PR_SET_NAME, name, 0, 0, 0); + Py_INCREF(Py_None); + return Py_None; +}; +#endif +#endif + #ifdef HAVE_KILL PyDoc_STRVAR(posix_kill__doc__, "kill(pid, sig)\n\n\ @@ -8770,6 +8808,12 @@ #ifdef __VMS {"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__}, #endif + #ifdef HAVE_SYS_PRCTL_H + {"getprocname", posix_getprocname, METH_VARARGS, posix_getprocname__doc__}, + #ifdef PR_SET_NAME + {"setprocname", posix_setprocname, METH_VARARGS, posix_setprocname__doc__}, + #endif + #endif {NULL, NULL} /* Sentinel */ }; @@ -9172,4 +9216,3 @@ } #endif - Index: pyconfig.h.in =================================================================== --- pyconfig.h.in (revisión: 71311) +++ pyconfig.h.in (copia de trabajo) @@ -697,6 +697,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_POLL_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PRCTL_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H