child process statistics

Sigbjorn Finne sof@galois.com
Fri, 28 Feb 2003 09:05:04 -0800


"Dean Herington" <heringto@cs.unc.edu> writes:
>
> On Wed, 26 Feb 2003, Sigbjorn Finne wrote:
>
> > wait3() or getrusage()? (Neither of which are supported
> > by the posix library.)
> >
> > --sigbjorn
>
> Thanks, Sigbjorn.  I drafted a Haskell wrapping of wait4(), modeled on
> code I found in CVS.  See attached. I'd like a bit of help in two
> respects:
>
> 1. I found it difficult to satisfy the code requirements because I'm
> building the module outside the RTS build environment.  Some issues:
>
>  a. I don't know how to make a .hsc file, which would be the appropriate
> form for the file, I think.  This meant I couldn't use #const, and may
> also explain why I couldn't find the __hsunix_* routines.
>

The HsUnix.h contain these helper routines, which you'll find in the
include/ subdir of the unix package.

>  c. I'm not sure how to define `struct timeval` and `struct rusage` so I
> can avoid the kludgy code in `makeProcessResourceUsage`.
>

hsc2hs does let you access fields of a struct without having to know
offsets nor struct sizes (cf. getProcessTimes in Process.hsc)

> It seems that maybe I should be building in the RTS environment (and
> maybe even extending the System.Posix.Process module itself) to clean
> up all of the above problems.  That seems a bit daunting to me, however.
>

That makes good sense. If you're over the hurdle of setting up and building
the fptools tree, there's really not much to it. Modify
libraries/unix/System/Posix/Process.hsc followed by a 'make' in
libraries/unix.
It uses the in-tree version of hsc2hs, so you don't have to worry about
setting it up.

> 2. Having gotten my module to compile cleanly, it--not surprisingly--fails
> at runtime:
>
> invalid argument
> Action: reapChildProcess
> Reason: Invalid argument
>

I can't see anything obviously wrong with the parameters, I'm assuming the
pid and the options settings are correct. Tracing the system calls will
probably
give you some useful info.

--sigbjorn