/* File : spawn2.c Purpose : According to VNI, WAVE uses the fork() library function to spawn child processes. This duplicates the process in memory, including all its variables. If the WAVE application is large the system runs out of memory when SPAWN is executed. This program uses system() rather than fork so a copy of the process is not made. Platform : SUN Sparc, SunOS 4.1.3, PV-WAVE, ANSI-C Make : cc -c -pic spawn2.c ld -o spawn2.so -assert pure-text spawn2.o Execute : To spawn a child process from WAVE : rv=LINKNLOAD('spawn2.so','spawn',command_string,return_string) To delete an unwanted file from WAVE : rv=LINKNLOAD('spawn2.so','rm',filename_string) where rv is the integer return value from the system() call. Author : T R Good, Space Dept., DERA Farnborough Revision : 1.00, 14 Apr 97 */ #include #include int spawn ( argc , argv ) int argc; void **argv; { char **cmd_string; if (argc!=1) { printf("%% spawn2.so[spawn]: command string required\n"); return(1); } cmd_string=((char ***)argv)[0]; return(system(cmd_string[0])); } int rm (argc , argv ) int argc; void **argv; { char **filename; if (argc!=1) { printf("%% spawn2.so[rm]: filename required\n"); return(1); } filename=((char ***)argv)[0]; if (unlink(filename[0])!=0) { printf("%% spawn2.so[rm]: file %s not found\n",filename[0]); return(0); } return(0); } /* end of file */