aboutsummaryrefslogtreecommitdiff
path: root/apps/examples/ostest
diff options
context:
space:
mode:
Diffstat (limited to 'apps/examples/ostest')
-rw-r--r--apps/examples/ostest/ostest_main.c28
-rw-r--r--apps/examples/ostest/waitpid.c18
2 files changed, 37 insertions, 9 deletions
diff --git a/apps/examples/ostest/ostest_main.c b/apps/examples/ostest/ostest_main.c
index aab1ff045..3e4197fdc 100644
--- a/apps/examples/ostest/ostest_main.c
+++ b/apps/examples/ostest/ostest_main.c
@@ -43,8 +43,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
#include <string.h>
#include <sched.h>
+#include <errno.h>
+
#include <nuttx/init.h>
#include "ostest.h"
@@ -264,6 +267,31 @@ static int user_main(int argc, char *argv[])
}
check_test_memory_usage();
+ /* If retention of child status is enable, then suppress it for this task.
+ * This task may produce many, many children (especially if
+ * CONFIG_EXAMPLES_OSTEST_LOOPS) and it does not harvest their exit status.
+ * As a result, the test may fail inappropriately unless retention of
+ * child exit status is disabled.
+ *
+ * So basically, this tests that child status can be disabled, but cannot
+ * verify that status is retained correctly.
+ */
+
+#if defined(CONFIG_SCHED_HAVE_PARENT) && defined(CONFIG_SCHED_CHILD_STATUS)
+ {
+ struct sigaction sa;
+ int ret;
+
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = SA_NOCLDWAIT;
+ ret = sigaction(SIGCHLD, &sa, NULL);
+ if (ret < 0)
+ {
+ printf("user_main: ERROR: sigaction failed: %d\n", errno);
+ }
+ }
+#endif
+
/* Check environment variables */
#ifndef CONFIG_DISABLE_ENVIRON
show_environment(true, true, true);
diff --git a/apps/examples/ostest/waitpid.c b/apps/examples/ostest/waitpid.c
index e53b49213..d45410265 100644
--- a/apps/examples/ostest/waitpid.c
+++ b/apps/examples/ostest/waitpid.c
@@ -113,14 +113,14 @@ static void waitpid_last(void)
printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n",
g_waitpids[NCHILDREN-1], errcode);
}
- else if (stat_loc != RETURN_STATUS)
+ else if (WEXITSTATUS(stat_loc) != RETURN_STATUS)
{
printf("waitpid_last: ERROR: PID %d return status is %d, expected %d\n",
- g_waitpids[NCHILDREN-1], stat_loc, RETURN_STATUS);
+ g_waitpids[NCHILDREN-1], WEXITSTATUS(stat_loc), RETURN_STATUS);
}
else
{
- printf("waitpid_last: PID %d waitpid succeeded with stat_loc=%d\n",
+ printf("waitpid_last: PID %d waitpid succeeded with stat_loc=%04x\n",
g_waitpids[NCHILDREN-1], stat_loc);
}
}
@@ -155,14 +155,14 @@ int waitpid_test(void)
printf("waitpid_test: ERROR: PID %d wait returned PID %d\n",
g_waitpids[0], ret);
}
- else if (stat_loc != RETURN_STATUS)
+ else if (WEXITSTATUS(stat_loc) != RETURN_STATUS)
{
printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n",
- g_waitpids[0], stat_loc, RETURN_STATUS);
+ g_waitpids[0], WEXITSTATUS(stat_loc), RETURN_STATUS);
}
else
{
- printf("waitpid_test: PID %d waitpid succeeded with stat_loc=%d\n",
+ printf("waitpid_test: PID %d waitpid succeeded with stat_loc=%04x\n",
g_waitpids[0], stat_loc);
}
@@ -246,14 +246,14 @@ int waitpid_test(void)
int errcode = errno;
printf("waitpid_test: ERROR: wait failed: %d\n", errcode);
}
- else if (stat_loc != RETURN_STATUS)
+ else if (WEXITSTATUS(stat_loc) != RETURN_STATUS)
{
printf("waitpid_test: ERROR: PID %d return status is %d, expected %d\n",
- ret, stat_loc, RETURN_STATUS);
+ ret, WEXITSTATUS(stat_loc), RETURN_STATUS);
}
else
{
- printf("waitpid_test: PID %d wait succeeded with stat_loc=%d\n",
+ printf("waitpid_test: PID %d wait succeeded with stat_loc=%04x\n",
ret, stat_loc);
}