Path: utzoo!utgpu!watmath!clyde!att!pacbell!ames!ncar!noao!asuvax!nud!fishpond!fnf
From: fnf@fishpond.UUCP (Fred Fish)
Newsgroups: comp.sys.amiga.tech
Subject: Re: problems with forkv (lattice)
Message-ID: <168@fishpond.UUCP>
Date: 29 Nov 88 00:58:03 GMT
References:  <167@fishpond.UUCP> 
Reply-To: fnf@fishpond.UUCP (Fred Fish)
Organization: occasionally
Lines: 75

In article  bader+@andrew.cmu.edu (Miles Bader) writes:
>fnf@fishpond.UUCP (Fred Fish) writes:
>> Forkv only works when the forked program is a C program.  This restriction
>> did not make it into the manual, but is apparently in one of the README
>Actually, I can't get it to work with c programs either.  I just
>tested it with a really small program that just does "exit(atoi(argv[1]))".
>...
>So my question (why doesn't forkv work?) still stands...

Hmmm...  I managed to dig up the test programs I was using when I was 
investigating this exact thing, while trying to use forkv to run a subshell
(subcli ???).  They are attached to this posting.

To test:

	lc -L forkv.c
	lc -L echo.c
	forkv echo a b c

	(this should run the echo program, which should echo it's arguments
	 and return 123, which gets printed by the forkv program)

	forkv newcli

	(boom!!!   guru  ...00004.XXXX...)

===================================  echo.c  ===================================
main (argc, argv)
int argc;
char **argv;
{
	while (argc-- > 0) {
		printf ("%s ", *argv++);
	}
	printf ("\n");
	exit (123);
}
===================================  forkv.c  ===================================
/*
 *	Sample forkv program from Lattice 4.0 manual.
 */

#include "dos.h"
#include "stdio.h"

struct ProcID child;

void main (argc, argv)
int argc;
char *argv[];
{
	int ret;

	if (argc < 2) {
		printf ("no program specified\n");
		printf ("usage: fork program [arg1] [arg2] ...\n");
		exit (0);
	}
	printf ("parent: beginning fork of %s\n", argv[1]);
	if (forkv (argv[1], &argv[1], NULL, &child) == -1) {
		printf ("error forking child\n");
		exit (0);
	} else {
		ret = wait (&child);
	}
	printf ("parent: %s finished, ret = %d\n", argv[1], ret);
}
======================================================================

Hope this helps to track down the problem.

-Fred
-- 
# Fred Fish, 1346 West 10th Place, Tempe, AZ 85281,  USA
# noao!nud!fishpond!fnf                   (602) 921-1113