Date: Fri, 8 Nov 2002 11:41:18 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: freebsd-questions@FreeBSD.ORG Subject: Re: trouble with perl writing to pipes :( Message-ID: <20021108114118.GA3823@happy-idiot-talk.infracaninophi> In-Reply-To: <20021108094643.GA3590@grummit.biaix.org> References: <20021108094643.GA3590@grummit.biaix.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 08, 2002 at 10:46:43AM +0100, Joan Picanyol i Puig wrote:
> I'm noticing some weird behaviour having perl writing to pipes (they eat
> my output):
>
> grummit:~/tmp/runwhen/dirs/root/runwhen/cvsup$ cat shownextrun
> #!/usr/bin/perl -w
> print('sleeping; next run at: ',
> scalar(localtime(time()+$ENV{'DELAY'})), "\n");
> exec({ $ARGV[0] } @ARGV);
>
> grummit:~/tmp/runwhen/dirs/root/runwhen/cvsup$ DELAY=1 ./shownextrun true
> sleeping; next run at: Fri Nov 8 10:44:21 2002
>
> grummit:~/tmp/runwhen/dirs/root/runwhen/cvsup$ DELAY=1 ./shownextrun true | cat
> grummit:~/tmp/runwhen/dirs/root/runwhen/cvsup$
You may find that appropriate use of the $| special variable (or
equivalently the autoflush method of the IO::Handle object) suddenly
makes things work a lot better.
Either that, or always write to a pipe in chunks of 4K at a time...
Hmmm... This only seems to affect perl-5.00503 --- perl-5.6.1 works
for me in the way you expect without any extra flushing.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021108114118.GA3823>
