Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 606edc1

Browse files
committed
Patch #568235: Add posix.setpgid.
1 parent 14f8b4c commit 606edc1

8 files changed

Lines changed: 41 additions & 3 deletions

File tree

Doc/lib/libos.tex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ \subsection{Process Parameters \label{os-procinfo}}
144144
Availability: \UNIX.
145145
\end{funcdesc}
146146

147+
\begin{funcdesc}{getpgid}{pid}
148+
Return the process group id of the process with process id \var{pid}.
149+
If \var{pid} is 0, the process group id of the current process is
150+
returned. Availability: \UNIX.
151+
\end{funcdesc}
152+
147153
\begin{funcdesc}{getpgrp}{}
148154
\index{process!group}
149155
Return the id of the current process group.

Mac/Include/pyconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
451451
#define HAVE_GETPEERNAME
452452
#endif
453453

454+
/* Define if you have the getpgid function. */
455+
#undef HAVE_GETPGID
456+
454457
/* Define if you have the getpgrp function. */
455458
#undef HAVE_GETPGRP
456459

Misc/NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ Extension modules
114114
This will create a temporary in-memory bsddb that won't be
115115
written to disk.
116116

117-
- posix.killpg and posix.mknod have been added where available.
117+
- posix.killpg, posix.mknod, and posix.getpgid have been added where
118+
available.
118119

119120
- The locale module now exposes the C library's gettext interface.
120121

Modules/posixmodule.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,6 +2117,25 @@ posix_getgroups(PyObject *self, PyObject *args)
21172117
}
21182118
#endif
21192119

2120+
#ifdef HAVE_GETPGID
2121+
static char posix_getpgid__doc__[] =
2122+
"getpgid(pid) -> pgid\n\
2123+
Call the system call getpgid().";
2124+
2125+
static PyObject *
2126+
posix_getpgid(PyObject *self, PyObject *args)
2127+
{
2128+
int pid, pgid;
2129+
if (!PyArg_ParseTuple(args, "i:getpgid", &pid))
2130+
return NULL;
2131+
pgid = getpgid(pid);
2132+
if (pgid < 0)
2133+
return posix_error();
2134+
return PyInt_FromLong((long)pgid);
2135+
}
2136+
#endif /* HAVE_GETPGID */
2137+
2138+
21202139
#ifdef HAVE_GETPGRP
21212140
PyDoc_STRVAR(posix_getpgrp__doc__,
21222141
"getpgrp() -> pgrp\n\
@@ -6406,6 +6425,9 @@ static PyMethodDef posix_methods[] = {
64066425
#ifdef HAVE_SETGROUPS
64076426
{"setgroups", posix_setgroups, METH_VARARGS, posix_setgroups__doc__},
64086427
#endif /* HAVE_SETGROUPS */
6428+
#ifdef HAVE_GETPGID
6429+
{"getpgid", posix_getpgid, METH_VARARGS, posix_getpgid__doc__},
6430+
#endif /* HAVE_GETPGID */
64096431
#ifdef HAVE_SETPGRP
64106432
{"setpgrp", posix_setpgrp, METH_VARARGS, posix_setpgrp__doc__},
64116433
#endif /* HAVE_SETPGRP */

RISCOS/pyconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,9 @@
404404
/* Define if you have the getpeername function. */
405405
#undef HAVE_GETPEERNAME
406406

407+
/* Define if you have the getpgid function. */
408+
#undef HAVE_GETPGID
409+
407410
/* Define if you have the getpgrp function. */
408411
#undef HAVE_GETPGRP
409412

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11449,7 +11449,7 @@ echo "${ECHO_T}MACHDEP_OBJS" >&6
1144911449
1145011450
for ac_func in alarm chown chroot clock confstr ctermid ctermid_r execv \
1145111451
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
11452-
gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
11452+
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
1145311453
hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \
1145411454
nice pathconf pause plock poll pthread_init \
1145511455
putenv readlink \

configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ AC_MSG_RESULT(MACHDEP_OBJS)
16211621
# checks for library functions
16221622
AC_CHECK_FUNCS(alarm chown chroot clock confstr ctermid ctermid_r execv \
16231623
fchdir flock fork fsync fdatasync fpathconf ftime ftruncate \
1624-
gai_strerror getgroups getlogin getpeername getpid getpwent getwd \
1624+
gai_strerror getgroups getlogin getpeername getpgid getpid getpwent getwd \
16251625
hstrerror inet_pton kill killpg link lstat mkfifo mknod mktime mremap \
16261626
nice pathconf pause plock poll pthread_init \
16271627
putenv readlink \

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@
176176
/* Define to 1 if you have the `getpeername' function. */
177177
#undef HAVE_GETPEERNAME
178178

179+
/* Define to 1 if you have the `getpgid' function. */
180+
#undef HAVE_GETPGID
181+
179182
/* Define to 1 if you have the `getpgrp' function. */
180183
#undef HAVE_GETPGRP
181184

0 commit comments

Comments
 (0)