CreateNewProc _start()
CreateNewProc _start()
i do read this in the autodoc about the NP_Entry tag
This entry() function has the same prototype as the _start()
Where do i find this prototype?
This entry() function has the same prototype as the _start()
Where do i find this prototype?
- salass00
- AmigaOS Core Developer
- Posts: 530
- Joined: Sat Jun 18, 2011 3:12 pm
- Location: Finland
- Contact:
Re: CreateNewProc _start()
In <dos/startup.h>:JosDuchIt wrote:i do read this in the autodoc about the NP_Entry tag
This entry() function has the same prototype as the _start()
Where do i find this prototype?
Code: Select all
/* Native AmigaDOS program _start() entry function definition. */
int32 _start( STRPTR argstring, int32 arglen, struct ExecBase *sysbase );
Re: CreateNewProc _start()
@salass00
thanks, now if i don't need any args what should my call look like ?
Second question: what should the called function do with the last argument provuded? (sysbase) ?
thanks, now if i don't need any args what should my call look like ?
Second question: what should the called function do with the last argument provuded? (sysbase) ?
- salass00
- AmigaOS Core Developer
- Posts: 530
- Joined: Sat Jun 18, 2011 3:12 pm
- Location: Finland
- Contact:
Re: CreateNewProc _start()
Just do like you would do with main() if you don't need argc & argv:JosDuchIt wrote:thanks, now if i don't need any args what should my call look like ?
Code: Select all
int32 _start(void) {
return 0;
}
Common usage is to obtain IExec pointer without needing to read from AbsExecBase:Second question: what should the called function do with the last argument provuded? (sysbase) ?
Code: Select all
struct ExecIFace *IExec = (struct ExecIFace *)sysbase->MainInterface;
- colinw
- AmigaOS Core Developer
- Posts: 207
- Joined: Mon Aug 15, 2011 9:20 am
- Location: Brisbane, QLD. Australia.
Re: CreateNewProc _start()
You must have an old SDK because the include/dos/startup.h file not only provides the correct prototypeJosDuchIt wrote: thanks, now if i don't need any args what should my call look like ?
Second question: what should the called function do with the last argument provuded? (sysbase) ?
info but also has example code and a list of mandatory caveats when starting new processes.
What is in the one you have ?
Re: CreateNewProc _start()
@colinw
I think i have a recent one & i guess the caveats you mention are these;
The example opens the dos.library
May i conclude
-that in a CreateNewProc addressed child entry function this opening & closing of dos.library is not needed ?
- hat any other library used in the child process should be opened in the child's entry function?
I think i have a recent one & i guess the caveats you mention are these;
* For this stand-alone DOS startup code example;
* 1) Only dos.library is opened and closed.
* 2) Any workbench startup message is simply fetched and replied to.
* 3) No global library bases or interfaces are initialised.
* 4) No parameters are used from the workbench message or cli.
The example opens the dos.library
May i conclude
-that in a CreateNewProc addressed child entry function this opening & closing of dos.library is not needed ?
- hat any other library used in the child process should be opened in the child's entry function?
Last edited by JosDuchIt on Sun Jan 18, 2015 8:07 pm, edited 1 time in total.
- colinw
- AmigaOS Core Developer
- Posts: 207
- Joined: Mon Aug 15, 2011 9:20 am
- Location: Brisbane, QLD. Australia.
Re: CreateNewProc _start()
After that you should have the following;
===========================================================================
*
* Mandatory Caveats;
* 1) It is never permissable to open libraries or call any dos.library
* functions or perform any i/o whatsoever, directly or indirectly
* from this process context, before a workbench startup message
* has been fetched from the process structure message port.
*
* 2) After replying to a workench startup message on exit, with the
* IExec->ReplyMsg() function, assume that all process locks and
* streams have gone away instantly, in other words, do nothing after
* the IExec->ReplyMsg() except releasing the exec interface and
* returning back to dos.library.
*
* 3) The _start() function is never to be declared as a void function.
*
* 4) Regardless of how a program is started, via workbench, via shell,
* a dos handler, or anything else, the only acceptable return codes
* are those from the include/dos/dos.h file. eg;
* RETURN_OK = 0 ( No problems, program exited successfully )
* RETURN_WARN = 5 ( Warning only, ie; for 'IF' shell command )
* RETURN_ERROR = 10 ( Something failed normally )
* RETURN_FAIL = 20 ( Severe failure, ie; missing system component )
*
* 5) A meaningfull secondary error code from dos/errors.h must always be
* returning when exiting with a primary code other than RETURN_OK.
*
===========================================================================
Then there is the basic startup example code folllowing....
As this kind of code is started in several ways in DOS, the RunCommand() documentation will explain
how this all works and what functions call what.
Just remember, if your new process code is running in the shared code space that was loaded by another process,
then NP_Child should be set to prevent disaster. Also remember that you must end all dependant child processes
before the parent can exit. There is extensive arbitration code examples at the bottom of the CreateNewProc() autodoc
Of couse, the easiest way to stay out of trouble is to not share resources, library interfaces and such like,
but open and close them from within the child process, same goes for files and locks, loadable code and such like.
===========================================================================
*
* Mandatory Caveats;
* 1) It is never permissable to open libraries or call any dos.library
* functions or perform any i/o whatsoever, directly or indirectly
* from this process context, before a workbench startup message
* has been fetched from the process structure message port.
*
* 2) After replying to a workench startup message on exit, with the
* IExec->ReplyMsg() function, assume that all process locks and
* streams have gone away instantly, in other words, do nothing after
* the IExec->ReplyMsg() except releasing the exec interface and
* returning back to dos.library.
*
* 3) The _start() function is never to be declared as a void function.
*
* 4) Regardless of how a program is started, via workbench, via shell,
* a dos handler, or anything else, the only acceptable return codes
* are those from the include/dos/dos.h file. eg;
* RETURN_OK = 0 ( No problems, program exited successfully )
* RETURN_WARN = 5 ( Warning only, ie; for 'IF' shell command )
* RETURN_ERROR = 10 ( Something failed normally )
* RETURN_FAIL = 20 ( Severe failure, ie; missing system component )
*
* 5) A meaningfull secondary error code from dos/errors.h must always be
* returning when exiting with a primary code other than RETURN_OK.
*
===========================================================================
Then there is the basic startup example code folllowing....
As this kind of code is started in several ways in DOS, the RunCommand() documentation will explain
how this all works and what functions call what.
Just remember, if your new process code is running in the shared code space that was loaded by another process,
then NP_Child should be set to prevent disaster. Also remember that you must end all dependant child processes
before the parent can exit. There is extensive arbitration code examples at the bottom of the CreateNewProc() autodoc
Of couse, the easiest way to stay out of trouble is to not share resources, library interfaces and such like,
but open and close them from within the child process, same goes for files and locks, loadable code and such like.
Re: CreateNewProc _start()
@coln thanks for additional info
@all
How come i have an old page?
Is not Amiupdate taking care of this?
@all
How come i have an old page?
Is not Amiupdate taking care of this?
Re: CreateNewProc _start()
My SDK has the information in startup.h that Colin referred to above. If you are using the latest SDK (v53.24) from the Hyperion WEB site you should have the same files too.JosDuchIt wrote:@coln thanks for additional info
@all
How come i have an old page?
Is not Amiupdate taking care of this?
AmigaOne X1000 with 2GB memory - OS4.1 FE
-
- Posts: 314
- Joined: Mon May 14, 2012 10:26 pm
- Location: 日本千葉県松戸市 / Matsudo City, Chiba, Japan
- Contact:
Re: CreateNewProc _start()
I have a similar "solution" to the above with a major point of difference in that...
There is no parent "process" as I have embedded my own dynamic process within a shared library and have it launched as a child of ramlib.
I've done this for Perception-IME and Polymorph-VMM core management processes as they are both designed for long-running client support.
I'm also setting up the library to forward MessageEvent handling through to the central process followed by some kind of sync option for a means of using a "return code".
Hopefully http://github.com/Belxjander/Perception-IME and http://github.com/Belxjander/Polymorph-VMM are useful
There is no parent "process" as I have embedded my own dynamic process within a shared library and have it launched as a child of ramlib.
I've done this for Perception-IME and Polymorph-VMM core management processes as they are both designed for long-running client support.
I'm also setting up the library to forward MessageEvent handling through to the central process followed by some kind of sync option for a means of using a "return code".
Hopefully http://github.com/Belxjander/Perception-IME and http://github.com/Belxjander/Polymorph-VMM are useful