Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!unisoft!bdt!david From: david@bdt.UUCP (David Beckemeyer) Newsgroups: comp.sys.atari.st Subject: Re: TOS io redirection bugs Message-ID: <1131@bdt.UUCP> Date: 2 Feb 90 03:11:04 GMT References: <1990Jan22.173721.12285@stag.UUCP> <2006@atari.UUCP> Reply-To: david@bdt.UUCP (David Beckemeyer) Organization: Beckemeyer Development Tools, Oakland, CA Lines: 63 In article <2006@atari.UUCP> apratt@atari.UUCP (Allan Pratt) writes: >Yes, Fdup / Fforce will gag when you get too deep, but Hblank is not >the answer. If you want to link programs with temporary files, great! >Add command-line options to each program in the chain which say, "Use >this file for input, that one for output." I had hoped that J.Bammi >could win you over to this point of view. Or you could just use MICRO RTX which has working Fdup / Force as well as Popen (pipe popen) so you don't even need to use temporary files. For example: int pfd[2]; int sav0; sav0 = Fdup(0); /* save stdin */ Popen(pfd); /* create pipe */ Fforce(0, pfd[0]); /* force child to read pipe as stdin */ Pexec(100, "child.prg", tail, env); /* start child (fork) */ Fforce(0, sav0); /* restore stdin (child is running now) */ Fclose(sav0); /* release the saved handle *./ /* write whatever we want to pipe */ Fwrite(pfd[1], (long)strlen(data), data); /* close write side */ Fclose(pfd[1]); You could also use multiple pipes to run several programs in a chain. You can also use Fdup / Fforce once on two different programs and Pexec one to write to the pipe and the other to read. For example, the equivalent (in simple terms) of the shell command "prog1 | prog2" can be done with: int sav0, sav1; int pfd[2]; Popen(pfd); sav1 = Fdup(1); Fforce(1, pfd[1]); Pexex(100, "prog1.prg", tail, env); Fforce(1, sav1); sav0 = Fdup(0); Fforce(0, pfd[0]); Pexec(0, "prog2.prg", tail, env); Fforce(0, sav0); Fclose(pfd[0]); Fclose(pfd[1]); Fclose(sav0); Fclose(sav1); > >============================================ >Opinions expressed above do not necessarily -- Allan Pratt, Atari Corp. >reflect those of Atari Corp. or anyone else. ...ames!atari!apratt -- David Beckemeyer (david@bdt.UUCP) | "I'll forgive you Dad... If you have Beckemeyer Development Tools | a breath mint." P.O. Box 21575, Oakland, CA 94620 | Bart - "The Simpsons" UUCP: {uunet,ucbvax}!unisoft!bdt!david |