Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!mucs!uk.ac.man.cs From: rogersh%t2e@uk.ac.man.cs (Huw J. Rogers) Newsgroups: comp.sys.acorn Subject: 'Shelling out' under RiscOS - the Ansilib system() function Keywords: Emacs Message-ID: <2623@m1.cs.man.ac.uk> Date: 5 Jun 91 11:53:42 GMT References: <906@vaxc.aud.auc.dk> <1991Jun4.004249.14376@cl.cam.ac.uk> <1991Jun04.090849.17348@comp.vuw.ac.nz> Sender: news@cs.man.ac.uk Organization: Murder Inc. Lines: 33 Under Release 3 or greater of the C compiler, Ansilib allows programs to call other programs via the system() function. In order to retain the 'parent' program in memory and return gracefully to it it does several things: 1) deinstall all handlers referencing 'parent' program 2) install an exit handler 3) copy up the 'parent' program to the top of memory 4) set HIMEM to just below this copy so it won't get overwritten 5) call OSCLI to run the 'child' program 6) OSCLI either returns or the 'child' program calls the exit handler, which takes us to 7) 7) reset HIMEM to previous value 8) deinstall exit handler 9) copy down 'parent' program to reinstall it 10) reinstall all handlers deinstalled in 1) 11) return from system() with appropriate exit code... What I want is some example code that does all that - in particular copes with problems with the stack that arise when messing about like this. This is a fairly common problem with any application that allows arbitrary OSCLI commands which can invoke subprograms, but there are several *nasty* complications - despite Acorn trying to make it sound simple to do this in the PRM section dealing with exit handlers. Thanks in advance, -Huw [ H.J.Rogers (INTERNET: rogersh%p4%cs.man.ac.uk@cunyvm.cuny.edu) ] [ ,_, (BITNET/EARN: rogersh%p4%cs.man.ac.uk@UKACRL.BITNET) ] [ :-(_)-o (UUCP: ...!uunet!cunyvm.cuny.edu!cs.man.ac.uk!p4!rogersh) ] [ _} {_ (JANET: rogersh%p4@uk.ac.man.cs) ]