/* startchild name: procedure name (either in search path or full path specified) cin: file which will be child's stdin cout: file which will be child's stdout 14 Mar 97. Write in 1 printf instead of 2 (got first line but not 2nd-hope this helps & doesn't eliminate both instead!) Exit w/errno instead of 1 if errno non-zero. WJS 3 Jun 96. Change error string so defgb can recognize it as error. WJS 30 May 96. Mod to child process behavior after failed exec. WJS 1) print error info to stdout instead of stderr and flush it, thus feeding message to parent 2) _exit() */ #include #include #include #if SOL || HP #include #include #endif startchild(name,cin,cout) char *name; FILE **cin, **cout; { static int pipeto[2],pipefrom[2]; int i,numfds,childpid; char *args[20]; #if SOL || HP struct rlimit rlp; #endif if (pipe(pipeto) || pipe(pipefrom) <0) { perror("no pipes"); exit(1); } switch(childpid = fork()) { case -1: perror("bad fork"); exit(1); case 0: /* fprintf(stderr,"got here after fork\n"); fprintf(stderr,"%s\n",name); */ dup2(pipeto[0],0); dup2(pipefrom[1],1); #if SOL || HP getrlimit(RLIMIT_NOFILE,&rlp); numfds=rlp.rlim_cur; #else numfds = getdtablesize(); #endif for (i=3; i