Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!rochester!pt.cs.cmu.edu!andrew.cmu.edu!bader+ From: bader+@andrew.cmu.edu (Miles Bader) Newsgroups: comp.sys.amiga.tech Subject: problems with forkv (lattice) Message-ID: Date: 27 Nov 88 16:49:34 GMT Organization: Carnegie Mellon Lines: 96 Despite many re-readings of the manual section, and talking to lattice technical support, I STILL can't forkv to work as advertised. At the end of this mesage is a short program illustrating my problems. I would be extremely grateful if anyone can point out any reasons why it doesn't work... Thanks, -Miles /* fail.c * * This program illustrates the problems I'm having with forkv: * 1) It doesn't use the search path as the manual claims; you have * to give an explicit path to the program you want to run, when * cli can find the same program as long its in a directory in your * path. * 2) The program guru's 100% of the time, both when USESTDIO is defined * or not. Examination of all the arguments to the forkv call at * run time doesn't give any clues due to bad arguments. * * Compile with: * lc -L fail.c * OR lc -L -dUSESTDIO fail.c * * It seems to occur no matter which program you use. The following * gurus, for instance (avail is a 1.3 program that lists availabe memory): * fail ram:output c:avail * * The behavior is the same under both versions 4.1 and 5.0 of Lattice-C. */ #include #include #include #include main(argc,argv) int argc; char **argv; { #ifdef USESTDIO FILE *outfp; struct UFB *ufb; #endif long outfh; static struct FORKENV env={0,0,0,0,0,NULL}; struct ProcID child; int status; if(argc<3){ fprintf(stderr,"Usage: %s outfp command arg ...\n",argv[0]); exit(-1); } argv++; #ifdef USESTDIO outfp=fopen(*argv++,"w"); if(outfp==NULL){ poserr("fopen"); exit(-1); } ufb=chkufb(fileno(outfp)); if(ufb==NULL){ fputs("ufb is NULL\n",stderr); fclose(outfp); exit(-1); } outfh=ufb->ufbfh; #else /* USESTDIO */ outfh=Open(*argv++,MODE_NEWFILE); if(outfh==0){ fputs("Open failed\n",stderr); exit(-1); } #endif env.std_out=outfh; status=forkv(argv[0],argv,&env,&child); if(status==-1) poserr("forkv"); else status=wait(&child); printf("Exit status is %d\n",status); #ifdef USESTDIO fclose(outfp); #else Close(outfh); #endif exit(status); }