ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Loughran <ste...@apache.org>
Subject Re: How to pipe output to input?
Date Fri, 24 Jun 2005 15:07:04 GMT
Matt Benson wrote:
> --- Steve Loughran <stevel@apache.org> wrote:
> [SNIP]
> 
>>I see. It is a lot easier to delegate to the OS,
>>isnt it:
>>
>><exec executable="mkfifo" osfamily="unix">
>>	<arg file="./pipe" />
>></exec>
> 
> 
> Well!  I am ashamed to say I had never encountered the
> mkfifo command.  My only contact with "named pipes"
> had been in O'Reilly's "Learning the bash shell" in
> which the  >(foo) and <(bar) constructs for piping
> to/from processes are covered briefly.  Named pipes
> are mentioned, I assume because they are implicitly
> created by this bash syntax.
> 
> I tried this:
> <exec executable="mkfifo">
>   <arg file="myfifo" />
> </exec>
> <parallel>
>   <echo file="myfifo">
> foo
> bar
> baz
> etc
>   </echo>
>   <concat>
>     <fileset file="myfifo" />
>   </concat>
> </parallel>
> <delete file="myfifo" />
> 
> and everything works as expected on Unix.  This also
> works on cygwin EXCEPT that the <delete> does not fail
> in Ant yet still fails to delete the pipe.  But since
> fifos would be implemented in god-only-knows-what-way
> that is unsurprising.  Cool.


well there you go, you have learned something new. I've been using named 
pipes where needed since, what, 1988. they are the most wonderfully 
minimal bit of IPC on the planet.

WinNT has named pipes for network shares, which are an explicit bit of 
remote IPC; you use  ::CreateNamedPipe to create them. The funny is they 
arent just simple nodes in the filesystem, they live in a special 
\\machine\pipe\ place:-
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/base/createnamedpipe.asp

I presume this is what cygwin is using, though I dont know how they map 
them to files in the filesystem, that is a miracle of hackery.

As with most bits of unix (i.e. symlinks), it is a shame that the Nt 
implementation isnt as seamless as the unix one. it means we can't 
easily work with it to provide a portable pipe mechanism that the OS 
handles. But if you can stick to unix,  pipes make a good IPC mechanism. 
And like I said, if you have a proper clustering OS, those pipes work 
across machines in the cluster.

-steve

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message