Path: news.daimi.aau.dk!not-for-mail From: Wilfried Rupflin Newsgroups: comp.lang.beta Subject: Re: BETA and Pipes Date: Mon, 3 Feb 1997 17:17:57 +0100 (MET) Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 111 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <199702031617.RAA06330@mjolner.mjolner.dk> Reply-To: Wilfried Rupflin NNTP-Posting-Host: daimi.daimi.aau.dk Xref: news.daimi.aau.dk comp.lang.beta:10952 Here is now my latest variant of Eriks example: >Hallo folks, > >I could't get the pipe-demo activate.bet to run. I have to use a pipe >in BETA. Can anyone help ? > >CP Hi, some time ago I received an example for pipes from Peter Andersen (and he got it from Erik Ernst in turn). I simplified it heavily and was happy -- until last week: I had to make hundreds of calls and ran out of file desriptors! And so I looked desperately for a close on pipes which I found in the end somewhere deep in '~beta/process/current/private/fdStream'. Hello Mjolner: please install a close on pipes in the proper place! Regards Wilfried PS to Peter: HOW DO YOU CLOSE PIPES PROPERLY? *---------------------------------------------------------------* | Wilfried Rupflin | wr@irb.informatik.uni-dortmund.de | | | ___ | | Universitaet Dortmund | //// | | FB Informatik, IRB | UNI DO// | | Postfach 500 500 | Tel.: +49 231 755 2478 ___ //// | | D-44221 Dortmund 50 | Fax.: +49 231 755 2386 \*\\/// | | Germany | Telex: 822465 unido d \\\\/ | *---------------------------------------------------------------* ORIGIN '~beta/basiclib/current/betaenv'; INCLUDE '~beta/process/current/processmanager'; INCLUDE '~beta/process/current/private/fdStream'; -- program: descriptor -- (* execread4.bet *) (* From: Peter Andersen Date: Thu, 21 Sep 95 9:56:55 BST _ even _more_ simplified _ *) (# execRead: (# name, args: ^text; output: ^stream; child: @process; channel: @pipe; enter (name[], args[]) do (* initialize (an object to manage) the child process *) name[] -> child.init; args[] -> child.argument.append; (* setup communication channel to retrieve output from child *) channel.init; channel.writeEnd[] -> child.redirectToChannel; channel.readEnd[] -> output[]; (* run the child process *) child.start; INNER; ( channel.readEnd[] -> QUA(# as:: fdStream #) ).close; #); do ('/bin/ls','-la') -> execRead (# do loop (# while:: (# do not output.eos -> value #); do output.getline -> putline; #); #); #) (* Notice that 1. "name" must be the full path of the command. You may add some code for searching through PATH for the command if you like. 2. ./. 3. There are other possible problems: - if the command does not exist or cannot be executed for any other reason, this is not detected. - the call blocks the BETA program while being executed. *)