- All Implemented Interfaces:
public class PipeEndpointListener
- extends Object
- implements Runnable
Runnable that reads messages from a given UNIX pipe.
The pipe will be opened in read/write mode. There are several reasons to
- Opening a pipe in read only mode blocks until the other end of the pipe is opened for writing
(see man 7 fifo). Since there is no
way to cleanly stop a thread blocking in the constructor of
FileInputStream we open
the pipe in read/write mode to avoid blocking.
- A pipe opened in read only mode will be closed when the other end is closed. By opening the pipe
in read/write mode we avoid this. If we unexpectedly receive an end-of-file, we shut down the
listener. This avoids unexpected behavior if the file system object is not a pipe (there is
no reliable way in Java to determine this).
- Read operations on the pipe are blocking. By opening the pipe in read/write mode we have a
simple way to wake up the listener thread to shut it down cleanly. However, since read/write
operations on a file channel can't be invoked concurrently from different threads,
we need to create two separate channels from the same file descriptor.
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public PipeEndpointListener(PipeEndpoint endpoint,
public void run()
- Specified by:
run in interface
public void stop()
Copyright © 2005-2012 Apache Software Foundation. All Rights Reserved.