Martin DiViaio on Fri, 11 Apr 2003 09:16:17 -0400 |
On the 11th day of April in the year 2003 you wrote: > Date: 11 Apr 2003 01:24:12 -0400 > From: Michael F. Robbins <mike@gamerack.com> > To: Philadelphia Linux User Group <plug@lists.phillylinux.org> > X-Spam-Status: No, hits=-0.5 required=5.0 > tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_05_08 > version=2.44 > Subject: Re: [PLUG] Linux FIFOs > > On Thu, 2003-04-10 at 22:47, Martin DiViaio wrote: > > I have a signature rotation script that creates a FIFO to output to. I > > then just point pine to the FIFO filename. This doesn't seem to want to > > work as it use to. > > I'm sure you've asked yourself already, but what changed? New version > of pine/your scripting language/kernel? > All three, actually. The original script ran under Pine 3.96 to 4.10, Perl 5.005, and kernels 2.0.36 thru 2.2.19. I haven't used the script since. I'm now running Pine 4.44, Perl 5.6.1 and kernel 2.4.21-pre4. > > and it would just start dumping sigs out until I CTRL-C'd the tail. It > > doesn't do this anymore. It reads the FIFO the first time then just hangs. > > The write program makes several more dumps to the FIFO then also hangs. > > If I kill the tail at that point, the write program dies with a broken > > pipe error. > > "man 4 fifo" might provide some insight. Also, make sure that you > aren't being thwarted by FIFO buffering. I imagine that this will be > specific to the language that you are using. (When I did some FIFO work > in C++ I had to be careful to keep flushing the stream after every > write.) I've read it and the information in Programming Perl. I think I'm doing this correctly - although I could be missing something stupid. > > To make sure the kernel FIFO behavior is sane, try it manually. Make a > FIFO file, cat > thefifo on one virtual console, and tail -f thefifo > (or run pine) on another VC. Ok... -- console 1 Belgarath:martin:~:1025 $ mkfifo fifo Belgarath:martin:~:1026 $ for i in 1 2 3 4 5 6 7 8 9 10; do echo -n "$i "; cat textfile > fifo; sleep 1 ; done 1 -- console 2 Belgarath:martin:~:1002 $ tail -f fifo this is the start of a text file this is some random text this is the end of a text file -- console 1 Belgarath:martin:~:1025 $ mkfifo fifo Belgarath:martin:~:1026 $ for i in 1 2 3 4 5 6 7 8 9 10; do echo -n "$i "; cat textfile > fifo; sleep 1 ; done 1 2 3 4 5 6 7 8 9 10 Belgarath:martin:~:1027 $ Console 2 will hang until I kill the tail. Thanks for your help. Here is the actual script. (Which acts the same way as above.) #!/usr/bin/perl -wT -- use strict; delete @ENV{qw/IFS CDPATH ENV BASH_ENV/}; $ENV{'PATH'}=''; $|++; my $quote_div="%\n"; my $credit_div="-----\n"; my $quote_file='/home/martin/docs/quotes'; my $sig_file='/home/martin/.signature/usermail'; my $output_stack='/home/martin/.signature/random_quote'; use Fcntl; use POSIX; my $unchanged_sig=''; open(IN1,"<${sig_file}"); while(<IN1>) { $unchanged_sig.=$_; } close IN1; my $temp_del=$/; $/=$quote_div; open(IN1,"<${quote_file}") || die "Can not open quote file for reading: ${!}\n"; my $quote_count=0; while(<IN1>) { $quote_count++; } close IN1; $/=$temp_del; unlink $output_stack; POSIX::mkfifo($output_stack,0600) || die "cannot mknod output stack: ${!}\n"; my($quote,$credit,$quote_number)=('','',0); while(1) { $quote_number=int(rand($quote_count)); print "${quote_number} "; $quote=''; $credit=''; $temp_del=$/; $/=$quote_div; open(IN1,"<${quote_file}") || die "cannot open quote file for reading (again): ${!}\n"; my $ln=''; for(my $i=1;$i<=$quote_number;$i++) { $ln=<IN1>; } close IN1; $/=$temp_del; $ln=~s/$quote_div//sgi; ($quote,$credit)=split $credit_div,$ln; $credit='' unless $credit; sysopen(OUT1,$output_stack,O_WRONLY); write OUT1; close OUT1; select(undef,undef,undef,0.2); } format OUT1 = @* $unchanged_sig @* $quote ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ $credit . _________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce General Discussion -- http://lists.netisland.net/mailman/listinfo/plug
|
|