Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdahl!ames!mike From: mike@ames.arpa (Mike Smithwick) Newsgroups: comp.sys.amiga Subject: Re: Processes Message-ID: <4680@ames.arpa> Date: 11 Feb 88 18:17:52 GMT References: <405@boole.acc.virginia.edu> <932@ur-tut.UUCP> <1029@stratus.UUCP> Reply-To: mike@ames.arc.nasa.gov.UUCP (Mike Smithwick) Organization: NASA Ames Research Center, Moffett Field, Calif. Lines: 72 Keywords: processes In article <1029@stratus.UUCP> conn@stratus.UUCP (Avery Shealey) writes: >Does anyone have some example code / information on starting processes >that they could send me? I have seen the example in Peck's book. > >What I want to do is to LoadSeg the process, CreateProc, set the input >and output streams, then detect the return value. I want the whole >procedure to be transparent to the process I am loading. > >So far I have got the process to load and execute, but no I/O shows up. >I got the I/O to show by setting pr_CIS and pr_COS to my own processes >CIS and COS, but after the process exits, hello mister guru. > >Any examples or information would be appreciated. > >Thanks, >Avery > The following is not transparent, as it requires the childproc to be aware of it's heritage, but it may give you some ideas. I've been working with Rob's examples for the past few days, and came across similar problems (I gather that his was Lattice, which is why it doesn't work under Manx). I wanted to do what he did, that is to get the stdio redirected to the parent's CLI window, which is what I gather you're trying to do. I tried the pr_CIS/COS trick, and couldn't get it to work right. If you look at the Manx startup source, _main.c, you'll see what Aztec does to set up stdio. Using that I did the following: The parent proc sends the input and output filehandles to the child which it gets from the Input() and Output() calls. The child picks them up and simply stuffs them into its "_devtab". mymessage=GetMsg(port); _devtab[0]=mymessage->std_input; _devtab[1]=mymessage->std_output; Now printfs will work okey-dokey from your childproc. When you're done, make sure to reassign the orignal stdio pointers, otherwise you'll meet Mr. Guru. _devtab[0]=Input(); _devtab[1]=Output(); exit(0); Now I am still having some problems which has to do with the magic of AmigaDog vs. Manx IO. In variations of the above said childproc, I need to do some file IO. When standalone, the traditional C fopen(), fprintf() etc works fine. When launched as a childproc using LoadSeg() . . . All of that breaks. Rob Peck's book suggests that fprintf() will work with a FileHandle returned by Open(), but no-go on this end (another Lattice convention?). Even Open() was flakey. Another bit of strangness having to do with the way Aztec sets up it's stdio pointers. I did a printf in the childproc before I modified the devtab[] entries. Afterwards printf wouldn't work at all. I gather that the first time a printf is called, Manx initializes some stuff which needs to get tweaked along with devtab[]. Can anyone shed some light?? -- *** mike (Mr. Bug) smithwick *** "the only thing wrong with reality, it that it takes too much time" [discalimer : nope, I don't work for NASA, I take full blame for my ideas]