[comp.sys.amiga.programmer] How to start INTERNAL residents

umueller@iiic.ethz.ch (Urban Dominik Mueller) (02/13/91)

I am currently upgrading the Dillon CShell and have a specific problem under
Kickstart 2.0. I'd like to start the internal residents (like the Path
command) from within my C program. So far the Shell used SyncRun(), but
as everybody knows, it only searches the Arp resident list. First I tried
to use System() for the job, but as this function creates a new process,
commands like CD and PATH won't work. Then I switched to (thanks, Matt)
FindSegment() plus RunCommand() plus SyncRunc(). This works fine for normal
residents (those made resident using the CLI Resident command) but the
INTERNAL residents will show a strange behaviour (of course they need a
separate FindSegment()). Once or twice they work, but after that they
ignore the command line arguments and read their arguments from stdin!
So anybody who's into the specialties of SYSTEM internals please email
me a working source or ask for my faulty version. I'll post the results
here.
       -Urban   (umueller@iiic.eth.ch)

jesup@cbmvax.commodore.com (Randell Jesup) (02/14/91)

In article <24675@neptune.inf.ethz.ch> umueller@iiic.ethz.ch (Urban Mueller) writes:
>I am currently upgrading the Dillon CShell and have a specific problem under
>Kickstart 2.0. I'd like to start the internal residents (like the Path
>command) from within my C program. So far the Shell used SyncRun(), but
>as everybody knows, it only searches the Arp resident list. First I tried
>to use System() for the job, but as this function creates a new process,
>commands like CD and PATH won't work. Then I switched to (thanks, Matt)
>FindSegment() plus RunCommand() plus SyncRunc(). This works fine for normal
>residents (those made resident using the CLI Resident command) but the
>INTERNAL residents will show a strange behaviour (of course they need a
>separate FindSegment()). Once or twice they work, but after that they
>ignore the command line arguments and read their arguments from stdin!
>So anybody who's into the specialties of SYSTEM internals please email
>me a working source or ask for my faulty version. I'll post the results
>here.

	We just finished documenting the resident structures and calls.
The INTERNAL commands have a seg_UC of -2, and you MUST NOT modify any
seg_UC that is less than 0.  System modules (shells, etc) have seg_UC's
of -1, and disabled internal commands are -999.  Do NOT add any other
negative values to the list (they're reserved for the moment).

	Your second problem is in the use of RunCommand.  Currently to work
right with any program that uses ReadArgs you must fudge the input FH to
have the arguments in the buffer.  We didn't want people doing this in their
code, so as of the next Beta RunCommand will do all the funky filehandle
magic for you.

	I advise against adding buffer-magic to your code, but if you must
please cause it to be disabled in V37 and above (2.0 through 2.02 for A3000's
are V36).  the next major release will be V37.

-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com  BIX: rjesup  
The compiler runs
Like a swift-flowing river
I wait in silence.  (From "The Zen of Programming")  ;-)