
From: Roland McGrath <roland@redhat.com>

The AIX results someone posted suggested that it does not clear siginfo_t
fields on WNOHANG early returns.  I still maintain that a POSIX application
must not assume that waitid will clear any fields.  However, since the
majority do, I see no harm in making Linux do so as well.

Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/kernel/exit.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletion(-)

diff -puN kernel/exit.c~waitid-clear-fields kernel/exit.c
--- 25/kernel/exit.c~waitid-clear-fields	2004-08-30 23:09:57.376505392 -0700
+++ 25-akpm/kernel/exit.c	2004-08-30 23:09:57.380504784 -0700
@@ -1322,8 +1322,29 @@ check_continued:
 end:
 	current->state = TASK_RUNNING;
 	remove_wait_queue(&current->wait_chldexit,&wait);
-	if (infop && retval > 0)
+	if (infop) {
+		if (retval > 0)
 		retval = 0;
+		else {
+			/*
+			 * For a WNOHANG return, clear out all the fields
+			 * we would set so the user can easily tell the
+			 * difference.
+			 */
+			if (!retval)
+				retval = put_user(0, &infop->si_signo);
+			if (!retval)
+				retval = put_user(0, &infop->si_errno);
+			if (!retval)
+				retval = put_user(0, &infop->si_code);
+			if (!retval)
+				retval = put_user(0, &infop->si_pid);
+			if (!retval)
+				retval = put_user(0, &infop->si_uid);
+			if (!retval)
+				retval = put_user(0, &infop->si_status);
+		}
+	}
 	return retval;
 }
 
_
