Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: Breaking a pipe Message-ID: <1990Apr11.084610.16131@iwarp.intel.com> Date: 11 Apr 90 08:46:10 GMT References: Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Distribution: comp Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 37 In-Reply-To: blarsen@spider.uio.no (Bjorn Larsen) In article , blarsen@spider (Bjorn Larsen) writes: | I have a Perl script that reads from a filehandle opened | with | open(F, "tail -f somefile |"); | | and at some point I want to close the filehandle and reopen it. | | However, according to the manpage, | | Also, closing a pipe will wait for | the process executing on the pipe to complete, in | case you want to look at the output of the pipe | afterwards. | | So, naturally my script goes blissfully to sleep waiting | for the pipe to complete. | | How do I break a pipe if I *don't* want to look at the output of | the pipe afterwards? Opening a pipe returns the process ID (PID) of the spawned shell, so hang on to the result of the open, as in: $Fpid = open(F,"tail -f somefile |"); and later when you want to make it go away, say: kill 9, $Fpid; close(F); The kill makes the process die, so the close returns immediately. eval q(eval q-eval q:print"Just another Perl hacker," :-) -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/