WCOREDUMP(), WIFCONTINUED(), WCONTINUED, WUNTRACED: New.

isatty(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(): Changed to return
    bools instead of ints.
This commit is contained in:
Fred Drake 2002-04-23 15:58:02 +00:00
parent 256705bca7
commit 106c1a0e7a
2 changed files with 113 additions and 17 deletions

View File

@ -420,8 +420,8 @@ Availability: \UNIX.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{isatty}{fd} \begin{funcdesc}{isatty}{fd}
Return \code{1} if the file descriptor \var{fd} is open and connected to a Return \code{True} if the file descriptor \var{fd} is open and
tty(-like) device, else \code{0}. connected to a tty(-like) device, else \code{False}.
Availability: \UNIX. Availability: \UNIX.
\end{funcdesc} \end{funcdesc}
@ -1225,24 +1225,56 @@ process status is available immediately.
Availability: \UNIX. Availability: \UNIX.
\end{datadesc} \end{datadesc}
\begin{datadesc}{WCONTINUED}
This option causes child processes to be reported if they have been
continued from a job control stop since their status was last
reported.
Availability: Some \UNIX{} systems.
\versionadded{2.3}
\end{datadesc}
\begin{datadesc}{WUNTRACED}
This option causes child processes to be reported if they have been
stopped but their current state has not been reported since they were
stopped.
Availability: \UNIX.
\versionadded{2.3}
\end{datadesc}
The following functions take a process status code as returned by The following functions take a process status code as returned by
\function{system()}, \function{wait()}, or \function{waitpid()} as a \function{system()}, \function{wait()}, or \function{waitpid()} as a
parameter. They may be used to determine the disposition of a parameter. They may be used to determine the disposition of a
process. process.
\begin{funcdesc}{WCOREDUMP}{status}
Returns \code{True} if a core dump was generated for the process,
otherwise it returns \code{False}.
Availability: \UNIX.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{WIFCONTINUED}{status}
Returns \code{True} if the process has been continued from a job
control stop, otherwise it returns \code{False}.
Availability: \UNIX.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{WIFSTOPPED}{status} \begin{funcdesc}{WIFSTOPPED}{status}
Return true if the process has been stopped. Returns \code{True} if the process has been stopped, otherwise it
returns \code{False}.
Availability: \UNIX. Availability: \UNIX.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{WIFSIGNALED}{status} \begin{funcdesc}{WIFSIGNALED}{status}
Return true if the process exited due to a signal. Returns \code{True} if the process exited due to a signal, otherwise
it returns \code{False}.
Availability: \UNIX. Availability: \UNIX.
\end{funcdesc} \end{funcdesc}
\begin{funcdesc}{WIFEXITED}{status} \begin{funcdesc}{WIFEXITED}{status}
Return true if the process exited using the \manpage{exit}{2} system Returns \code{True} if the process exited using the \manpage{exit}{2}
call. system call, otherwise it returns \code{False}.
Availability: \UNIX. Availability: \UNIX.
\end{funcdesc} \end{funcdesc}

View File

@ -4529,8 +4529,8 @@ posix_fdopen(PyObject *self, PyObject *args)
} }
static char posix_isatty__doc__[] = static char posix_isatty__doc__[] =
"isatty(fd) -> Boolean\n\ "isatty(fd) -> bool\n\
Return true if the file descriptor 'fd' is an open file descriptor\n\ Return True if the file descriptor 'fd' is an open file descriptor\n\
connected to the slave end of a terminal."; connected to the slave end of a terminal.";
static PyObject * static PyObject *
@ -4539,7 +4539,7 @@ posix_isatty(PyObject *self, PyObject *args)
int fd; int fd;
if (!PyArg_ParseTuple(args, "i:isatty", &fd)) if (!PyArg_ParseTuple(args, "i:isatty", &fd))
return NULL; return NULL;
return Py_BuildValue("i", isatty(fd)); return PyBool_FromLong(isatty(fd));
} }
#ifdef HAVE_PIPE #ifdef HAVE_PIPE
@ -4823,10 +4823,65 @@ posix_strerror(PyObject *self, PyObject *args)
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#ifdef WCOREDUMP
static char posix_WCOREDUMP__doc__[] =
"WCOREDUMP(status) -> bool\n\
Return True if the process returning 'status' was dumped to a core file.";
static PyObject *
posix_WCOREDUMP(PyObject *self, PyObject *args)
{
#ifdef UNION_WAIT
union wait status;
#define status_i (status.w_status)
#else
int status;
#define status_i status
#endif
status_i = 0;
if (!PyArg_ParseTuple(args, "i:WCOREDUMP", &status_i))
{
return NULL;
}
return PyBool_FromLong(WCOREDUMP(status));
#undef status_i
}
#endif /* WCOREDUMP */
#ifdef WIFCONTINUED
static char posix_WIFCONTINUED__doc__[] =
"WIFCONTINUED(status) -> bool\n\
Return True if the process returning 'status' was continued from a\n\
job control stop.";
static PyObject *
posix_WCONTINUED(PyObject *self, PyObject *args)
{
#ifdef UNION_WAIT
union wait status;
#define status_i (status.w_status)
#else
int status;
#define status_i status
#endif
status_i = 0;
if (!PyArg_ParseTuple(args, "i:WCONTINUED", &status_i))
{
return NULL;
}
return PyBool_FromLong(WCONTINUED(status));
#undef status_i
}
#endif /* WIFCONTINUED */
#ifdef WIFSTOPPED #ifdef WIFSTOPPED
static char posix_WIFSTOPPED__doc__[] = static char posix_WIFSTOPPED__doc__[] =
"WIFSTOPPED(status) -> Boolean\n\ "WIFSTOPPED(status) -> bool\n\
Return true if the process returning 'status' was stopped."; Return True if the process returning 'status' was stopped.";
static PyObject * static PyObject *
posix_WIFSTOPPED(PyObject *self, PyObject *args) posix_WIFSTOPPED(PyObject *self, PyObject *args)
@ -4845,15 +4900,15 @@ posix_WIFSTOPPED(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
return Py_BuildValue("i", WIFSTOPPED(status)); return PyBool_FromLong(WIFSTOPPED(status));
#undef status_i #undef status_i
} }
#endif /* WIFSTOPPED */ #endif /* WIFSTOPPED */
#ifdef WIFSIGNALED #ifdef WIFSIGNALED
static char posix_WIFSIGNALED__doc__[] = static char posix_WIFSIGNALED__doc__[] =
"WIFSIGNALED(status) -> Boolean\n\ "WIFSIGNALED(status) -> bool\n\
Return true if the process returning 'status' was terminated by a signal."; Return True if the process returning 'status' was terminated by a signal.";
static PyObject * static PyObject *
posix_WIFSIGNALED(PyObject *self, PyObject *args) posix_WIFSIGNALED(PyObject *self, PyObject *args)
@ -4872,14 +4927,14 @@ posix_WIFSIGNALED(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
return Py_BuildValue("i", WIFSIGNALED(status)); return PyBool_FromLong(WIFSIGNALED(status));
#undef status_i #undef status_i
} }
#endif /* WIFSIGNALED */ #endif /* WIFSIGNALED */
#ifdef WIFEXITED #ifdef WIFEXITED
static char posix_WIFEXITED__doc__[] = static char posix_WIFEXITED__doc__[] =
"WIFEXITED(status) -> Boolean\n\ "WIFEXITED(status) -> bool\n\
Return true if the process returning 'status' exited using the exit()\n\ Return true if the process returning 'status' exited using the exit()\n\
system call."; system call.";
@ -4900,7 +4955,7 @@ posix_WIFEXITED(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
return Py_BuildValue("i", WIFEXITED(status)); return PyBool_FromLong(WIFEXITED(status));
#undef status_i #undef status_i
} }
#endif /* WIFEXITED */ #endif /* WIFEXITED */
@ -6407,6 +6462,9 @@ static PyMethodDef posix_methods[] = {
{"fdatasync", posix_fdatasync, METH_O, posix_fdatasync__doc__}, {"fdatasync", posix_fdatasync, METH_O, posix_fdatasync__doc__},
#endif #endif
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#ifdef WCOREDUMP
{"WCOREDUMP", posix_WCOREDUMP, METH_VARARGS, posix_WCOREDUMP__doc__},
#endif /* WCOREDUMP */
#ifdef WIFSTOPPED #ifdef WIFSTOPPED
{"WIFSTOPPED", posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__}, {"WIFSTOPPED", posix_WIFSTOPPED, METH_VARARGS, posix_WIFSTOPPED__doc__},
#endif /* WIFSTOPPED */ #endif /* WIFSTOPPED */
@ -6541,9 +6599,15 @@ all_ins(PyObject *d)
#ifdef TMP_MAX #ifdef TMP_MAX
if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1; if (ins(d, "TMP_MAX", (long)TMP_MAX)) return -1;
#endif #endif
#ifdef WCONTINUED
if (ins(d, "WCONTINUED", (long)WCONTINUED)) return -1;
#endif
#ifdef WNOHANG #ifdef WNOHANG
if (ins(d, "WNOHANG", (long)WNOHANG)) return -1; if (ins(d, "WNOHANG", (long)WNOHANG)) return -1;
#endif #endif
#ifdef WUNTRACED
if (ins(d, "WUNTRACED", (long)WUNTRACED)) return -1;
#endif
#ifdef O_RDONLY #ifdef O_RDONLY
if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1; if (ins(d, "O_RDONLY", (long)O_RDONLY)) return -1;
#endif #endif