www.delorie.com/gnu/docs/greg/greg_26.html   search  
 
Buy GNU books!


Greg testing framework

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.0.8.1 Starting a child process

Greg provides the greg-child procedure to start up a child process on a pseudo-terminal. You would usually call this procedure in the `begin.grg' file in your tool directory, but you could call it at the start of each script to get a new child process for each script.

The greg-child procedure expects one argument (the name of the program to be executed) followed by any number of additional arguments which are the arguments to be passed to the child process.
If the program name does not begin with a slash, Greg will look in the directory specified in greg-obj-dir to find it (by default the current directory).
If you want your normal PATH to be searched for the program, you should use -
(greg-child "/bin/sh" "-c" "foo args")
to get the shell to execute program `foo' with arguments args.

The greg-child procedure will automatically close down the I/O channels to any process previously started and wait for that process to die. If the old child process is badly behaved and will not die, this can result in Greg hanging - in this case you may need to explicitly kill the old child by another method before starting the new child process (this is one of the uses of the `end.grg' script).

As a special case, you can use an empty string as the program name - if you do this, another copy of the guile process will be created as a child and the value returned by greg-child in the child process will be a list containing the single number 0 (in the parent it will be a list containing the input port, output port and process id of the child). You can use this information to get the child copy of the process to be the program under test. This is useful for embedded testing where you want to test the I/O capabilities of the program.

NB. The greg-child procedure is implemented on top of the new primitive pty-child. This primitive is used to create a new child process on the end of a pseudo-terminal. Arguments and return values are as for greg-child.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003