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

Skip to content

Commit b2c92f4

Browse files
committed
Patch #511193: Implement killpg in posixmodule.
1 parent b4779c3 commit b2c92f4

5 files changed

Lines changed: 351 additions & 336 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Core and builtins
1313
Previously, an xreadlines object was returned which would raise
1414
a ValueError when the xreadlines.next() method was called.
1515

16+
- posix.killpg has been added where available.
17+
1618
Extension modules
1719

1820
- dl now builds on every system that has dlfcn.h. Failure in case

Modules/posixmodule.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,6 +2199,24 @@ posix_kill(PyObject *self, PyObject *args)
21992199
}
22002200
#endif
22012201

2202+
#ifdef HAVE_KILLPG
2203+
static char posix_killpg__doc__[] =
2204+
"killpg(pgid, sig) -> None\n\
2205+
Kill a process group with a signal.";
2206+
2207+
static PyObject *
2208+
posix_killpg(PyObject *self, PyObject *args)
2209+
{
2210+
int pgid, sig;
2211+
if (!PyArg_ParseTuple(args, "ii:killpg", &pgid, &sig))
2212+
return NULL;
2213+
if (killpg(pgid, sig) == -1)
2214+
return posix_error();
2215+
Py_INCREF(Py_None);
2216+
return Py_None;
2217+
}
2218+
#endif
2219+
22022220
#ifdef HAVE_PLOCK
22032221

22042222
#ifdef HAVE_SYS_LOCK_H
@@ -5573,6 +5591,9 @@ static PyMethodDef posix_methods[] = {
55735591
#ifdef HAVE_KILL
55745592
{"kill", posix_kill, METH_VARARGS, posix_kill__doc__},
55755593
#endif /* HAVE_KILL */
5594+
#ifdef HAVE_KILLPG
5595+
{"killpg", posix_killpg, METH_VARARGS, posix_killpg__doc__},
5596+
#endif /* HAVE_KILLPG */
55765597
#ifdef HAVE_PLOCK
55775598
{"plock", posix_plock, METH_VARARGS, posix_plock__doc__},
55785599
#endif /* HAVE_PLOCK */

0 commit comments

Comments
 (0)