MorphOS Developer
Posts: 1520 from 2003/2/24
From: Finland
Quote:
ausPPC wrote:
I'm starting to regret giving away my RKMs... Can anyone recommend a good discussion or primer on process initialisation as it applies to MorphOS? My goal is to create a new process that doesn't have to initialise itself any differently to a 'normal', user-started process.
RKRMs never covered any dos.library calls... I dont know why, I always found it weird.
To create new process just call:
struct Process *proc = CreateNewProcTags(NP_Entry, MyProcessFunc, NP_Name, "My Child Process", NP_CodeType, CODETYPE_PPC, TAG_DONE);
You may want to pass additional parameters to your entry. Lets say your process call is like this:
void MyProcessFunc(struct Data *data, CONST_STRPTR path) { /.../ }
You just add NP_PPC_Arg1, data, NP_PPC_Arg2, "RAM:MyPath" to tag list.
Quote:
I'm particularly interested to know how to initialise the following tags marked with a '*'. Is it acceptable for the parent process to simply copy certain fields from its own process structure to pair with these tags?
Just let the OS copy those fields for you.
Quote:
NP_Input *
NP_Output *
NP_CloseInput *
NP_CloseOutput *
NP_Error *
NP_CloseError *
If you want to pass your own filehandles for input, output and error you can Open() one yourself. CloseInput/Output/Error is just a boolean flag to indicate if the launched process should close those handles automatically when the launched process ends.
Quote:
NP_CurrentDir *
You can pass your own lock here... but it is not necessary.
Quote:
NP_ConsoleTask * (How is this different to NP_Cli ?)
Dont worry about this one...
Quote:
NP_WindowPtr * (Just out of curiousity, can a parent and child process draw to the same window?)
This is used as a reference pointer for DOS requesters. You dont have to worry about this either...
Quote:
NP_HomeDir *
You can set homedir here but it is not necessary.
Quote:
NP_CopyVars * (How is this used?)
This mean local environment variables.
Quote:
NP_Cli *
NP_Path *
Too low level to me. I have never used, never needed, never had to understand.
Quote:
NP_Arguments * (Is this just a string pointer?)
Yes it is, however, I prefer using NP_PPC_Arg tags.
Quote:
NP_TaskMsgPort * (Does the parent create this or is it handled by process creation?)
This is handled by process creation. You can use this tag to get TaskMsgPort of newly created process:
struct MsgPort *port;
NP_TaskMsgPort, &port
This can be used for interprocess communication and its advantage is that you can avoid usual handshaking mechanism with parent and child process.
[ Edited by itix 08.03.2016 - 11:56 ]1 + 1 = 3 with very large values of 1