Skip to content

Commit cd1376d

Browse files
committed
Merged revisions 72855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r72855 | antoine.pitrou | 2009-05-23 18:06:49 +0200 (sam., 23 mai 2009) | 3 lines Some pid_t-expecting or producing functions were forgotten in r72852. ........
1 parent 794b3fc commit cd1376d

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

Modules/posixmodule.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,7 +3816,7 @@ Return the current process id");
38163816
static PyObject *
38173817
posix_getpid(PyObject *self, PyObject *noargs)
38183818
{
3819-
return PyInt_FromLong((long)getpid());
3819+
return PyLong_FromPid(getpid());
38203820
}
38213821

38223822

@@ -3870,13 +3870,13 @@ Call the system call getpgid().");
38703870
static PyObject *
38713871
posix_getpgid(PyObject *self, PyObject *args)
38723872
{
3873-
int pid, pgid;
3874-
if (!PyArg_ParseTuple(args, "i:getpgid", &pid))
3873+
pid_t pid, pgid;
3874+
if (!PyArg_ParseTuple(args, PARSE_PID ":getpgid", &pid))
38753875
return NULL;
38763876
pgid = getpgid(pid);
38773877
if (pgid < 0)
38783878
return posix_error();
3879-
return PyInt_FromLong((long)pgid);
3879+
return PyLong_FromPid(pgid);
38803880
}
38813881
#endif /* HAVE_GETPGID */
38823882

@@ -3890,9 +3890,9 @@ static PyObject *
38903890
posix_getpgrp(PyObject *self, PyObject *noargs)
38913891
{
38923892
#ifdef GETPGRP_HAVE_ARG
3893-
return PyInt_FromLong((long)getpgrp(0));
3893+
return PyLong_FromPid(getpgrp(0));
38943894
#else /* GETPGRP_HAVE_ARG */
3895-
return PyInt_FromLong((long)getpgrp());
3895+
return PyLong_FromPid(getpgrp());
38963896
#endif /* GETPGRP_HAVE_ARG */
38973897
}
38983898
#endif /* HAVE_GETPGRP */
@@ -3926,7 +3926,7 @@ Return the parent's process id.");
39263926
static PyObject *
39273927
posix_getppid(PyObject *self, PyObject *noargs)
39283928
{
3929-
return PyInt_FromLong(getppid());
3929+
return PyLong_FromPid(getppid());
39303930
}
39313931
#endif
39323932

@@ -4015,8 +4015,13 @@ Kill a process group with a signal.");
40154015
static PyObject *
40164016
posix_killpg(PyObject *self, PyObject *args)
40174017
{
4018-
int pgid, sig;
4019-
if (!PyArg_ParseTuple(args, "ii:killpg", &pgid, &sig))
4018+
int sig;
4019+
pid_t pgid;
4020+
/* XXX some man pages make the `pgid` parameter an int, others
4021+
a pid_t. Since getpgrp() returns a pid_t, we assume killpg should
4022+
take the same type. Moreover, pid_t is always at least as wide as
4023+
int (else compilation of this module fails), which is safe. */
4024+
if (!PyArg_ParseTuple(args, PARSE_PID "i:killpg", &pgid, &sig))
40204025
return NULL;
40214026
if (killpg(pgid, sig) == -1)
40224027
return posix_error();
@@ -6181,8 +6186,9 @@ Set the process group associated with the terminal given by a fd.");
61816186
static PyObject *
61826187
posix_tcsetpgrp(PyObject *self, PyObject *args)
61836188
{
6184-
int fd, pgid;
6185-
if (!PyArg_ParseTuple(args, "ii:tcsetpgrp", &fd, &pgid))
6189+
int fd;
6190+
pid_t pgid;
6191+
if (!PyArg_ParseTuple(args, "i" PARSE_PID ":tcsetpgrp", &fd, &pgid))
61866192
return NULL;
61876193
if (tcsetpgrp(fd, pgid) < 0)
61886194
return posix_error();

0 commit comments

Comments
 (0)