Fix some compilation errors when child status disabled; new waitpid logic not encoding/decoding status properly

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5561 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-25 00:01:08 +00:00
parent a2ec48846f
commit b6472b58dc
7 changed files with 26 additions and 24 deletions
+2
View File
@@ -493,3 +493,5 @@
* apps/netutils/telnetd/telnetd_driver: Was stuck in a loop if * apps/netutils/telnetd/telnetd_driver: Was stuck in a loop if
recv[from]() ever returned a value <= 0. recv[from]() ever returned a value <= 0.
* apps/examples/nettest and poll: Complete Kconfig files. * apps/examples/nettest and poll: Complete Kconfig files.
* apps/examples/ostest/waitpid.c: Need to use WEXITSTATUS()
to decode the correct exit status.
+9 -9
View File
@@ -113,14 +113,14 @@ static void waitpid_last(void)
printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n", printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n",
g_waitpids[NCHILDREN-1], errcode); 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", 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 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); 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", printf("waitpid_test: ERROR: PID %d wait returned PID %d\n",
g_waitpids[0], ret); 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", 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 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); g_waitpids[0], stat_loc);
} }
@@ -246,14 +246,14 @@ int waitpid_test(void)
int errcode = errno; int errcode = errno;
printf("waitpid_test: ERROR: wait failed: %d\n", errcode); 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", 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 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); ret, stat_loc);
} }
+1 -1
View File
@@ -123,7 +123,7 @@ int pthread_join(pthread_t thread, FAR pthread_addr_t *pexit_value)
* This can fail for one of three reasons: (1) There is no * This can fail for one of three reasons: (1) There is no
* thread associated with 'thread,' (2) the thread is a task * thread associated with 'thread,' (2) the thread is a task
* and does not have join information, or (3) the thread * and does not have join information, or (3) the thread
* was detached and has exitted. * was detached and has exited.
*/ */
pjoin = pthread_findjoininfo((pid_t)thread); pjoin = pthread_findjoininfo((pid_t)thread);
+6 -6
View File
@@ -54,16 +54,16 @@
*****************************************************************************/ *****************************************************************************/
/***************************************************************************** /*****************************************************************************
* Name: exitted_child * Name: exited_child
* *
* Description: * Description:
* Handle the case where a child exitted properlay was we (apparently) lost * Handle the case where a child exited properlay was we (apparently) lost
* the detch of child signal. * the detch of child signal.
* *
*****************************************************************************/ *****************************************************************************/
#ifdef CONFIG_SCHED_CHILD_STATUS #ifdef CONFIG_SCHED_CHILD_STATUS
static void exitted_child(FAR _TCB *rtcb, FAR struct child_status_s *child, static void exited_child(FAR _TCB *rtcb, FAR struct child_status_s *child,
FAR siginfo_t *info) FAR siginfo_t *info)
{ {
/* The child has exited. Return the saved exit status (and some fudged /* The child has exited. Return the saved exit status (and some fudged
@@ -271,11 +271,11 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
if (retains && (child = task_exitchild(rtcb)) != NULL) if (retains && (child = task_exitchild(rtcb)) != NULL)
{ {
/* A child has exitted. Apparently we missed the signal. /* A child has exited. Apparently we missed the signal.
* Return the exit status and break out of the loop. * Return the exit status and break out of the loop.
*/ */
exitted_child(rtcb, child, info); exited_child(rtcb, child, info);
break; break;
} }
} }
@@ -297,7 +297,7 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
* of the loop. * of the loop.
*/ */
exitted_child(rtcb, child, info); exited_child(rtcb, child, info);
break; break;
} }
} }
+5 -5
View File
@@ -384,13 +384,13 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
DEBUGASSERT(!retains || rtcb->children); DEBUGASSERT(!retains || rtcb->children);
if (retains && (child = task_exitchild(rtcb)) != NULL) if (retains && (child = task_exitchild(rtcb)) != NULL)
{ {
/* A child has exitted. Apparently we missed the signal. /* A child has exited. Apparently we missed the signal.
* Return the saved exit status. * Return the saved exit status.
*/ */
/* The child has exited. Return the saved exit status */ /* The child has exited. Return the saved exit status */
*stat_loc = child->ch_status; *stat_loc = child->ch_status << 8;
/* Discard the child entry and break out of the loop */ /* Discard the child entry and break out of the loop */
@@ -415,7 +415,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
{ {
/* The child has exited. Return the saved exit status */ /* The child has exited. Return the saved exit status */
*stat_loc = child->ch_status; *stat_loc = child->ch_status << 8;
/* Discard the child entry and break out of the loop */ /* Discard the child entry and break out of the loop */
@@ -452,7 +452,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
*/ */
if (rtcb->nchildren == 0 || if (rtcb->nchildren == 0 ||
(pid != (pid_t)-1 && (ret = kill((pid_t)id, 0)) < 0)) (pid != (pid_t)-1 && (ret = kill(pid, 0)) < 0))
{ {
/* We know that the child task was running okay we stared, /* We know that the child task was running okay we stared,
* so we must have lost the signal. What can we do? * so we must have lost the signal. What can we do?
@@ -481,7 +481,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
{ {
/* Yes... return the status and PID (in the event it was -1) */ /* Yes... return the status and PID (in the event it was -1) */
*stat_loc = info.si_status; *stat_loc = info.si_status << 8;
pid = info.si_pid; pid = info.si_pid;
break; break;
} }
+2 -2
View File
@@ -121,7 +121,7 @@ static void task_dumpchildren(FAR _TCB *tcb, FAR const char *msg)
} }
} }
#else #else
# task_dumpchildren(t,m) # define task_dumpchildren(t,m)
#endif #endif
/***************************************************************************** /*****************************************************************************
@@ -320,7 +320,7 @@ FAR struct child_status_s *task_exitchild(FAR _TCB *tcb)
{ {
FAR struct child_status_s *child; FAR struct child_status_s *child;
/* Find the status structure with the matching PID */ /* Find the status structure of any child task that has exitted. */
for (child = tcb->children; child; child = child->flink) for (child = tcb->children; child; child = child->flink)
{ {
+1 -1
View File
@@ -137,7 +137,7 @@ void weak_function timer_initialize(void)
* resources are referenced. * resources are referenced.
* *
* Parameters: * Parameters:
* pid - the task ID of the thread that exitted * pid - the task ID of the thread that exited
* *
* Return Value: * Return Value:
* None * None