[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem with time package, struct rusage and wait3



On Tue, Jul 31, 2001 at 02:42:34PM +0000, thomas@groupe-internet.com wrote:
> Hi
> 
> I looked to the package time and I think I found an error.
> The package didn't build because during the configure phase, it tried to
> test if wait3 fills correctly the rusage struct.
> Under the Hurd, it doesn't.
> I attached test.c.
> Under Linux, struct rusage is modified after return of wait3.
> 
> I didn't test the rusage function.

According to POSIX the rusage structure should be filled if it's not
NULL. Ironically, Hurd uses the wait3 implementation from
[glibc]/sysdeps/posix/wait3.c, which does not do that. Attached is
a patch to bring it to POSIX compliance.

Igor

2001-07-31  Igor Khavkine  <i_khavki@alcor.concordia.ca>

	* sysdeps/posix/wait3.c (__wait3): Fill in the USAGE argument
	if it is not NULL. This change is required for POSIX compliance.

--- glibc-2.2.3/sysdeps/posix/wait3.c.orig	Tue Jul 31 10:08:05 2001
+++ glibc-2.2.3/sysdeps/posix/wait3.c	Tue Jul 31 10:10:07 2001
@@ -29,12 +29,17 @@
 pid_t
 __wait3 (__WAIT_STATUS stat_loc, int options, struct rusage *usage)
 {
+	int err;
+
   if (usage != NULL)
     {
       __set_errno (ENOSYS);
       return (pid_t) -1;
     }
-  return __waitpid (WAIT_ANY, stat_loc.__iptr, options);
+  err = __waitpid (WAIT_ANY, stat_loc.__iptr, options);
+	if (!err && usage)
+		err = getrusage (RUSAGE_CHILDREN, usage);
+	return err;
 }
 
 weak_alias (__wait3, wait3)

Reply to: