protected void handleProcessTimeout ( String [ ] cmd ) throws IOException { StringBuilder bld = new StringBuilder ( ) ; boolean first = true ; for ( String c : cmd ) { if ( first ) { first = false ; } else { bld . append ( " " ) ; } String esc = Strings . escape ( c ) ; // Quote where escaping is needed, OR the argument // contains a literal space. if ( ! c . equals ( esc ) || c . contains ( " " ) ) { bld . append ( ' ' ) . append ( esc ) . append ( ' ' ) ; } else { bld . append ( c ) ; } } throw new IOException ( "Process took too long: " + bld . toString ( ) ) ; }
Handle timeout on the process finishing .