Commit 8399f1b9 authored by Christian Heimes's avatar Christian Heimes

Fixed bug #1983: Return from fork() is pid_t, not int

parent 5100888f
......@@ -122,6 +122,10 @@ typedef Py_intptr_t Py_ssize_t;
/* Smallest negative value of type Py_ssize_t. */
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
#if SIZEOF_PID_T > SIZEOF_LONG
# error "Python doesn't support sizeof(pid_t) > sizeof(long)"
#endif
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
* format to convert an argument with the width of a size_t or Py_ssize_t.
* C99 introduced "z" for this purpose, but not all platforms support that;
......@@ -573,7 +577,7 @@ extern char * _getpty(int *, int, mode_t, int);
functions, even though they are included in libutil. */
#include <termios.h>
extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
extern int forkpty(int *, char *, struct termios *, struct winsize *);
extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
......
......@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Bug #1983: Fixed return type of fork(), fork1() and forkpty() calls.
Python expected the return type int but the fork familie returns pi_t.
- Issue #1678380: Fix a bug that identifies 0j and -0j when they appear
in the same code unit.
......@@ -1386,6 +1389,9 @@ Tools/Demos
Build
-----
- Bug #1983: Added a check to pyport to verify that sizeof(pid_t) is
smaller or equal sizeof(long).
- Bug #1234: Fixed semaphore errors on AIX 5.2
- Issue #1726: Remove Python/atof.c from PCBuild/pythoncore.vcproj
......
......@@ -3575,11 +3575,11 @@ Return 0 to child process and PID of child to parent process.");
static PyObject *
posix_fork1(PyObject *self, PyObject *noargs)
{
int pid = fork1();
pid_t pid = fork1();
if (pid == -1)
return posix_error();
PyOS_AfterFork();
return PyInt_FromLong((long)pid);
return PyInt_FromLong(pid);
}
#endif
......@@ -3593,12 +3593,12 @@ Return 0 to child process and PID of child to parent process.");
static PyObject *
posix_fork(PyObject *self, PyObject *noargs)
{
int pid = fork();
pid_t pid = fork();
if (pid == -1)
return posix_error();
if (pid == 0)
PyOS_AfterFork();
return PyInt_FromLong((long)pid);
return PyInt_FromLong(pid);
}
#endif
......@@ -3700,14 +3700,15 @@ To both, return fd of newly opened pseudo-terminal.\n");
static PyObject *
posix_forkpty(PyObject *self, PyObject *noargs)
{
int master_fd = -1, pid;
int master_fd = -1;
pid_t pid;
pid = forkpty(&master_fd, NULL, NULL, NULL);
if (pid == -1)
return posix_error();
if (pid == 0)
PyOS_AfterFork();
return Py_BuildValue("(ii)", pid, master_fd);
return Py_BuildValue("(li)", pid, master_fd);
}
#endif
......
This diff is collapsed.
......@@ -1202,7 +1202,7 @@ AC_TYPE_PID_T
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE(ssize_t,
AC_CHECK_TYPE(ssize_t,
AC_DEFINE(HAVE_SSIZE_T, 1, Define if your compiler provides ssize_t),,)
# Sizes of various common basic types
......@@ -1215,6 +1215,7 @@ AC_CHECK_SIZEOF(float, 4)
AC_CHECK_SIZEOF(double, 8)
AC_CHECK_SIZEOF(fpos_t, 4)
AC_CHECK_SIZEOF(size_t, 4)
AC_CHECK_SIZEOF(pid_t, 4)
AC_MSG_CHECKING(for long long support)
have_long_long=no
......
......@@ -869,6 +869,9 @@
/* The number of bytes in an off_t. */
#undef SIZEOF_OFF_T
/* The size of `pid_t', as computed by sizeof. */
#undef SIZEOF_PID_T
/* The number of bytes in a pthread_t. */
#undef SIZEOF_PTHREAD_T
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment