[comp.sources.wanted] code for spawn off subprocesses on LAN

nieh@geae2.steinmetz (nico nieh) (01/11/89)

I am looking for a piece of program (a function) in C which can be
used on sun-3 and sun-4. I believe it has been done many times.
For an experienced UNIX system programmer it may be an easy job.
It may take me couple days to do it. If you have it (or similar piece of code)
and would like to share it please e-mail to me directly. 
It is appreciated, if you are interesting in helping me develop this function
by giving me some advise.
thanks in advance.

----------------------------------------------------------
The purpose of this function is to spawn off several subprocesses
on remote nodes and wait for all subprocesses to terminate.
Subprocesses may be a shell script, an executable image or an interpreter
file.

The specification as: (assume .rhosts files are properly setup)

#include <sys/time.h>
struct sub_program {
   char *node;           /* remote node name, if == NULL means current node*/
   char *program_name;   /* remote program name*/
   int  argn;            /* number of arguments to the program */
   char **argv;          /* actual arguments to the remote program */
   char *stdout_file;    /* standard output stored in this file when done */
   char *stderr_file;    /* standard error stored in this file when done */
   timeval *timeout;     /* abort this program after this much time*/
   void (* fp)();        /* a pointer to a function, this function will be
			    executed if the subprocess has a normal termination
		          */
   int return_status;    /*  1  = normal successful termination
        		    -2 = abnormal termination (core dump)
                            -3 = time out
 			    -4 = remote node is not available
                             other possible error messages
                            other = exit status
                          */
}; 
sub_program  *these_programs;
int          number_of_subprograms;
void spawn_several_subprocesses(number_of_subprograms,these_programs)

-------------------------------------------------------------


Ko-Haw Nieh

General Electric Company               | ARPA: nieh@ge-crd.arpa            
Corporate Research and Development     | UUCP: nieh@boston.steinmetz.ge.com 
P.O BOX 8, K1-ES224 		       | UUCP: {uunet!}steinmetz!nieh!crd  
Schenectady, NY 12301		       | 518-387-7431