🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #1373

starting a task

#1373
From: Joseph P. Larson
Date: Thu, 21 Sep 1989 20:43
44 lines
1709 bytes
Okay.  I know I might be able to dig this up before anyone here can get
to me, but I'm not sure, so....

I want to do the equivalent of:

	childpid = fork();
	if (childpid == -1) /* there is an error */
	else if (childpid) /* I'm the parent etc etc */
	else dochildprocess();

dochildprocess()
{
	while (i should stick around)
		dostuff;
	exit(0);
}

I think I can handle the fork() aspect of it by calling AddTask and
giving it the address of dochildprocess as such:

	tc = AllocMem(etc);
	stack = AllocMem(etc);
	tc->tc_SPLower = (APTR)stack;
	tc->tc_SPUpper = (APTR)(stacksize + stack);
	tc->tc_SPReg = tc->tc_SPUpper;
	tc->tc_Node.ln_Type = NT_TASK;
	tc->tc_Node.ln_Name = "mytaskname";

	AddTask(tc, dochildprocess, 0L);

However, how do I implement the call to exit()?  I would prefer that the
child free all his resources, but the parent can if necessary.  But it is
much preferred if the child can do it.

So -- anyone have any examples?  I looked at dmouse and launch, but they
both create processes rather than tasks and use LoadSeg() and all that
stuff......

-Joe
-- 
Life is a cabaret (old chum).
UUCP: rutgers!dayton!joe   (Picts 1-13 are   DHDSC - Joe Larson/MIS 1060
ATT : (612) 375-3537       now ready.)       700 on the Mall, Mpls, Mn. 55402
Technical Details
Message-ID: <6771@dayton.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!jtsv16!uunet!ginosko!aplcen!uakari.primate.wisc.edu!uwm.edu!bionet!apple!rutgers!dayton!joe

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!jtsv16!uunet!ginosko!aplcen!uakari.primate.wisc.edu!uwm.edu!bionet!apple!rutgers!dayton!joe
From: joe@dayton.UUCP (Joseph P. Larson)
Newsgroups: comp.sys.amiga.tech
Subject: starting a task
Message-ID: <6771@dayton.UUCP>
Date: 21 Sep 89 20:43:54 GMT
Reply-To: joe@dayton.UUCP (Joseph P. Larson)
Distribution: usa
Organization: Dayton-Hudson Dept. Store Co.
Lines: 44