From owner-freebsd-questions Fri Nov 8 3:41:28 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 89D7137B404 for ; Fri, 8 Nov 2002 03:41:27 -0800 (PST) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id C9C1943E3B for ; Fri, 8 Nov 2002 03:41:25 -0800 (PST) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [IPv6:::1]) by smtp.infracaninophile.co.uk (8.12.6/8.12.6) with ESMTP id gA8BfNtf004204 for ; Fri, 8 Nov 2002 11:41:23 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost) by happy-idiot-talk.infracaninophile.co.uk (8.12.6/8.12.6/Submit) id gA8BfIK0004199 for freebsd-questions@FreeBSD.ORG; Fri, 8 Nov 2002 11:41:18 GMT Date: Fri, 8 Nov 2002 11:41:18 +0000 From: Matthew Seaman To: freebsd-questions@FreeBSD.ORG Subject: Re: trouble with perl writing to pipes :( Message-ID: <20021108114118.GA3823@happy-idiot-talk.infracaninophi> Mail-Followup-To: Matthew Seaman , freebsd-questions@FreeBSD.ORG References: <20021108094643.GA3590@grummit.biaix.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021108094643.GA3590@grummit.biaix.org> User-Agent: Mutt/1.5.1i X-Spam-Status: No, hits=-3.0 required=5.0 tests=IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01, USER_AGENT,USER_AGENT_MUTT version=2.43 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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