public void run()

in src/main/java/com/pastdev/jsch/nio/file/UnixSshPathINotifyWatchKey.java [62:91]


    public void run() {
        StringBuilder commandBuilder = new StringBuilder( dir.getFileSystem().getCommand( "inotifywait" ) )
                .append( " -m -e create -e modify -e delete  --format '%:e" ).append( SEPARATOR ).append( "%f' " )
                .append( dir.toAbsolutePath().quotedString() );

        try {
            // duplicate the command runner so that we can close it causing the
            // underlying socket to exit to _interrupt_ the buffered reader.
            // http://stackoverflow.com/a/3596072/516433
            commandRunner = dir.getFileSystem().getCommandRunner().duplicate();

            ChannelExecWrapper channel = commandRunner.open( commandBuilder.toString() );
            try (BufferedReader reader = new BufferedReader( new InputStreamReader( channel.getInputStream() ) )) {
                String line = null;
                while ( (line = reader.readLine()) != null ) {
                    event( line );
                }
            }
        }
        catch ( IOException e ) {
            logger.debug( "watch service failed: ", e.getMessage() );
        }
        catch ( ClosedWatchServiceException e ) {
            logger.debug( "watch service was closed, so exit" );
        }
        finally {
            closeCommandRunner();
        }
        logger.info( "poller stopped for {}", dir );
    }