[Nickle] pipe() is dead, long live mkchild()

Bart Massey bart at cs.pdx.edu
Mon Oct 13 00:33:34 PDT 2003


With Keith's help, I've completely reworked Nickle's child
process support.  (Well, I'm not done yet, but it is
working somewhat. :-)

The pipe() primitive wasn't usable as is (and the name was
hopeless).  It's gone now---if you were using it, sorry.  In
its place are two new primitives:

  file[*] File::mkpipe()
    returns the obvious thing: 2 file descriptors that
    are the input and output sides of a UNIX pipe.
  
  int File::filter(string path, string[*] argv, file[*] fds)
    runs the program at the given path (environment lookups
    are performed IIRC) with the given arguments, and with
    the given 3 file descriptors in the fds[] array for
    child stdin, stdout, and stderr.  It currently returns
    the child PID.

Layered atop this is a "convenience" interface:

   public typedef union {
     file input;
     file output;
     file error;
   } childfd;

  int File::mkchild(string path, string[*] argv, childfd fds ...)
    marshals the files passed to it and passes them to
    filter(). Unsupplied positions default to stdnull.

Oh yeah, I also added stdnull, which defaults to "/dev/null"
on UNIX boxes, but may need to be specially implemented in
Windows.  It's just too useful.


Unfortunately, the interface still isn't right. There's no
current way to find out the exit status of a child process,
or to wait() for it.  Keith has Nickle collecting status on
SIGCHLD to clean up zombies, but AFAIK there's no way to
access it yet.  Further, there should be a provision to get
the pipes created automatically when starting the child
process, although I haven't yet figured the right interface
out.

Other than that, should do pretty much what you want.

	Bart



More information about the Nickle mailing list