diff options
author | Guido van Rossum <guido@python.org> | 1999-01-27 17:53:11 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-01-27 17:53:11 (GMT) |
commit | 54ecc3d24f52ae45ca54a24167e434915c88b60f (patch) | |
tree | 2bc2d15f1e6a6178a992a9ce0b4975697f1ef71b /Modules/posixmodule.c | |
parent | b5cebfe164fbf6c862e8aa9fb91628d1b8cf76be (diff) | |
download | cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.zip cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.gz cpython-54ecc3d24f52ae45ca54a24167e434915c88b60f.tar.bz2 |
Patches by William Lewis for Nextstep descendants.
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 119 |
1 files changed, 94 insertions, 25 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8ac5d96..19c7809 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -146,6 +146,7 @@ corresponding Unix manual entries for more information on calls."; #undef HAVE_UTIME_H #define HAVE_WAITPID /* #undef HAVE_GETCWD */ +#define UNION_WAIT /* This should really be checked for by autoconf */ #endif #ifdef HAVE_UNISTD_H @@ -255,6 +256,23 @@ extern int lstat Py_PROTO((const char *, struct stat *)); #include <io.h> #endif /* OS2 */ +#ifdef UNION_WAIT +/* Emulate some macros on systems that have a union instead of macros */ + +#ifndef WIFEXITED +#define WIFEXITED(u_wait) (!(u_wait).w_termsig && !(u_wait).w_coredump) +#endif + +#ifndef WEXITSTATUS +#define WEXITSTATUS(u_wait) (WIFEXITED(u_wait)?((u_wait).w_retcode):-1) +#endif + +#ifndef WTERMSIG +#define WTERMSIG(u_wait) ((u_wait).w_termsig) +#endif + +#endif /* UNION_WAIT */ + /* Return a dictionary corresponding to the POSIX environment table */ #if !defined(_MSC_VER) && ( !defined(__WATCOMC__) || defined(__QNX__) ) @@ -1986,20 +2004,25 @@ posix_waitpid(self, args) PyObject *self; PyObject *args; { - int pid, options, sts = 0; + int pid, options; +#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_Parse(args, "(ii)", &pid, &options)) return NULL; Py_BEGIN_ALLOW_THREADS -#ifdef NeXT - pid = wait4(pid, (union wait *)&sts, options, NULL); -#else - pid = waitpid(pid, &sts, options); -#endif + pid = wait4(pid, &status, options, NULL); Py_END_ALLOW_THREADS if (pid == -1) return posix_error(); else - return Py_BuildValue("ii", pid, sts); + return Py_BuildValue("ii", pid, status_i); } #endif /* HAVE_WAITPID */ @@ -2015,17 +2038,21 @@ posix_wait(self, args) PyObject *args; { int pid, sts; - Py_BEGIN_ALLOW_THREADS -#ifdef NeXT - pid = wait((union wait *)&sts); +#ifdef UNION_WAIT + union wait status; +#define status_i (status.w_status) #else - pid = wait(&sts); + int status; +#define status_i status #endif + status_i = 0; + Py_BEGIN_ALLOW_THREADS + pid = wait(&status); Py_END_ALLOW_THREADS if (pid == -1) return posix_error(); else - return Py_BuildValue("ii", pid, sts); + return Py_BuildValue("ii", pid, status_i); } #endif @@ -2821,9 +2848,16 @@ posix_WIFSTOPPED(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } @@ -2842,9 +2876,16 @@ posix_WIFSIGNALED(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } @@ -2863,9 +2904,16 @@ posix_WIFEXITED(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } @@ -2874,7 +2922,7 @@ posix_WIFEXITED(self, args) } #endif /* WIFEXITED */ -#ifdef WIFSTOPPED +#ifdef WEXITSTATUS static char posix_WEXITSTATUS__doc__[] = "WEXITSTATUS(status) -> integer\n\ See Unix documentation."; @@ -2884,9 +2932,16 @@ posix_WEXITSTATUS(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } @@ -2905,9 +2960,16 @@ posix_WTERMSIG(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } @@ -2926,9 +2988,16 @@ posix_WSTOPSIG(self, args) PyObject *self; PyObject *args; { - int status = 0; +#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_Parse(args, "i", &status)) + if (!PyArg_Parse(args, "i", &status_i)) { return NULL; } |