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

Skip to content

Commit c964179

Browse files
committed
Patch by Jody Winston (with my changes) to add some of the "wait
status inspection" macros as functions: WEXITSTATUS(), WIFEXITED(), WIFSIGNALED(), WIFSTOPPED(), WSTOPSIG(), WTERMSIG().
1 parent 923fece commit c964179

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

Modules/posixmodule.c

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,137 @@ posix_strerror(self, args)
24792479
#endif /* strerror */
24802480

24812481

2482+
#ifdef HAVE_SYS_WAIT_H
2483+
2484+
#ifdef WIFSTOPPED
2485+
static char posix_WIFSTOPPED__doc__[] =
2486+
"WIFSTOPPED(status) -> Boolean\n\
2487+
See Unix documentation.";
2488+
2489+
static PyObject *
2490+
posix_WIFSTOPPED(self, args)
2491+
PyObject *self;
2492+
PyObject *args;
2493+
{
2494+
int status = 0;
2495+
2496+
if (!PyArg_Parse(args, "i", &status))
2497+
{
2498+
return NULL;
2499+
}
2500+
2501+
return Py_BuildValue("i", WIFSTOPPED(status));
2502+
}
2503+
#endif /* WIFSTOPPED */
2504+
2505+
#ifdef WIFSIGNALED
2506+
static char posix_WIFSIGNALED__doc__[] =
2507+
"WIFSIGNALED(status) -> Boolean\n\
2508+
See Unix documentation.";
2509+
2510+
static PyObject *
2511+
posix_WIFSIGNALED(self, args)
2512+
PyObject *self;
2513+
PyObject *args;
2514+
{
2515+
int status = 0;
2516+
2517+
if (!PyArg_Parse(args, "i", &status))
2518+
{
2519+
return NULL;
2520+
}
2521+
2522+
return Py_BuildValue("i", WIFSIGNALED(status));
2523+
}
2524+
#endif /* WIFSIGNALED */
2525+
2526+
#ifdef WIFEXITED
2527+
static char posix_WIFEXITED__doc__[] =
2528+
"WIFEXITED(status) -> Boolean\n\
2529+
See Unix documentation.";
2530+
2531+
static PyObject *
2532+
posix_WIFEXITED(self, args)
2533+
PyObject *self;
2534+
PyObject *args;
2535+
{
2536+
int status = 0;
2537+
2538+
if (!PyArg_Parse(args, "i", &status))
2539+
{
2540+
return NULL;
2541+
}
2542+
2543+
return Py_BuildValue("i", WIFEXITED(status));
2544+
}
2545+
#endif /* WIFEXITED */
2546+
2547+
#ifdef WIFSTOPPED
2548+
static char posix_WEXITSTATUS__doc__[] =
2549+
"WEXITSTATUS(status) -> integer\n\
2550+
See Unix documentation.";
2551+
2552+
static PyObject *
2553+
posix_WEXITSTATUS(self, args)
2554+
PyObject *self;
2555+
PyObject *args;
2556+
{
2557+
int status = 0;
2558+
2559+
if (!PyArg_Parse(args, "i", &status))
2560+
{
2561+
return NULL;
2562+
}
2563+
2564+
return Py_BuildValue("i", WEXITSTATUS(status));
2565+
}
2566+
#endif /* WEXITSTATUS */
2567+
2568+
#ifdef WTERMSIG
2569+
static char posix_WTERMSIG__doc__[] =
2570+
"WTERMSIG(status) -> integer\n\
2571+
See Unix documentation.";
2572+
2573+
static PyObject *
2574+
posix_WTERMSIG(self, args)
2575+
PyObject *self;
2576+
PyObject *args;
2577+
{
2578+
int status = 0;
2579+
2580+
if (!PyArg_Parse(args, "i", &status))
2581+
{
2582+
return NULL;
2583+
}
2584+
2585+
return Py_BuildValue("i", WTERMSIG(status));
2586+
}
2587+
#endif /* WTERMSIG */
2588+
2589+
#ifdef WSTOPSIG
2590+
static char posix_WSTOPSIG__doc__[] =
2591+
"WSTOPSIG(status) -> integer\n\
2592+
See Unix documentation.";
2593+
2594+
static PyObject *
2595+
posix_WSTOPSIG(self, args)
2596+
PyObject *self;
2597+
PyObject *args;
2598+
{
2599+
int status = 0;
2600+
2601+
if (!PyArg_Parse(args, "i", &status))
2602+
{
2603+
return NULL;
2604+
}
2605+
2606+
return Py_BuildValue("i", WSTOPSIG(status));
2607+
}
2608+
#endif /* WSTOPSIG */
2609+
2610+
#endif /* HAVE_SYS_WAIT_H */
2611+
2612+
24822613
static PyMethodDef posix_methods[] = {
24832614
{"chdir", posix_chdir, 0, posix_chdir__doc__},
24842615
{"chmod", posix_chmod, 0, posix_chmod__doc__},
@@ -2606,6 +2737,26 @@ static PyMethodDef posix_methods[] = {
26062737
#ifdef HAVE_STRERROR
26072738
{"strerror", posix_strerror, 1, posix_strerror__doc__},
26082739
#endif
2740+
#ifdef HAVE_SYS_WAIT_H
2741+
#ifdef WIFSTOPPED
2742+
{"WIFSTOPPED", posix_WIFSTOPPED, 0, posix_WIFSTOPPED__doc__},
2743+
#endif /* WIFSTOPPED */
2744+
#ifdef WIFSIGNALED
2745+
{"WIFSIGNALED", posix_WIFSIGNALED, 0, posix_WIFSIGNALED__doc__},
2746+
#endif /* WIFSIGNALED */
2747+
#ifdef WIFEXITED
2748+
{"WIFEXITED", posix_WIFEXITED, 0, posix_WIFEXITED__doc__},
2749+
#endif /* WIFEXITED */
2750+
#ifdef WEXITSTATUS
2751+
{"WEXITSTATUS", posix_WEXITSTATUS, 0, posix_WEXITSTATUS__doc__},
2752+
#endif /* WEXITSTATUS */
2753+
#ifdef WTERMSIG
2754+
{"WTERMSIG", posix_WTERMSIG, 0, posix_WTERMSIG__doc__},
2755+
#endif /* WTERMSIG */
2756+
#ifdef WSTOPSIG
2757+
{"WSTOPSIG", posix_WSTOPSIG, 0, posix_WSTOPSIG__doc__},
2758+
#endif /* WSTOPSIG */
2759+
#endif /* HAVE_SYS_WAIT_H */
26092760
{NULL, NULL} /* Sentinel */
26102761
};
26112762

0 commit comments

Comments
 (0)