home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d188
/
null.lha
/
Null
/
amigaline-D1
< prev
next >
Wrap
Text File
|
1989-02-26
|
2KB
|
67 lines
AMIGALINE #D1, Matthew Dillon
Disconnecting a program such that you can EndCLI and also allow the
program to call Execute().
Problem:
You want to disconnect a program such that when you RUN <nil: >nil:
(using the new 1.3 RUN) you can then EndCLI the cli.
This program wants to be able to use Execute() to run other programs.
The problem is that Execute() requires a valid pr_ConsoleTask (console)
or it will freeze.
Solution: General
Run <nil: >nil: mycprogram
If using the main() entry point, you can fclose(stderr) to remove
the reference to "*". If using the _main() entry point, stdio is
not setup and thus you do not need to do this (in fact, you can't
use stdio at all without crashing the computer).
note: being able to fclose(stderr) from the main() entry point
works with Aztec C. I don't know about Lattice. Aztec always
does an Open("*", 1006) to setup stderr and this reference must
be removed.
--
At this point, you can EndCLI and the cli window goes away. However,
the 'mycprogram' cannot call Execute() or otherwise run other
external programs for two reasons:
(1) pr_ConsoleTask is still non-NULL and points to the now
defunct window (i.e. you will cause a task-held requester)
(2) you cannot set pr_ConsoleTask to NULL... Execute() does
not accept it and freezes up.
--
So, you must set pr_ConsoleTask to some other valid device. Guess
what? Any device will do except NIL: which isn't a real device. For
example, RAM: :
extern APTR DeviceProc();
proc->pr_ConsoleTask = DeviceProc("ram:");
(assuming RAM: exists)
What does this do? Any program which tries to open the console will
actually open the file "RAM:*", as in Open("RAM:*", 1006).
Unfortunetly, there is no way to place "*" in anything but the
root directory of the device. This is essentially a garbage file.
But the ultimate goal is achieved ... you can kill the CLI window
and still arbitrarily run programs from the detached program with
impunity.
The only possible problem which I have yet to test is when several
programs try to access RAM:* as their console at the same time.
Since the file is openned 1006, other programs trying to Open() it
will fail while the first programs is still running. What happens?
-Matt