Buggy code:
final class ManagedProcess { private final String processName ; private final List < String > command ; private final Map < String , String > env ; private final String workingDirectory ; private final ProcessLogger log ; private final Object lock ; private final ProcessController processController ; private final byte [ ] authKey ; private final boolean isPrivileged ; private final RespawnPolicy respawnPolicy ; private OutputStream stdin ; private volatile ManagedProcess . State state = ManagedProcess . State . DOWN ; private Process process ; private boolean shutdown ; private boolean stopRequested = false ; private final AtomicInteger respawnCount = new AtomicInteger ( 0 ) ; public byte [ ] getAuthKey ( ) { } public boolean isPrivileged ( ) { } public boolean isRunning ( ) { } public boolean isStopping ( ) { } enum State { DOWN , STARTED , STOPPING ; } ManagedProcess ( final String processName , final List < String > command , final Map < String , String > env , final String workingDirectory , final Object lock , final ProcessController controller , final byte [ ] authKey , final boolean privileged , final boolean respawn ) { } int incrementAndGetRespawnCount ( ) { } int resetRespawnCount ( ) { } public String getProcessName ( ) { } public void start ( ) { } public void sendStdin ( final InputStream msg ) throws IOException { } public void reconnect ( String hostName , int port , boolean managementSubsystemEndpoint , byte [ ] asAuthKey ) { } void doStart ( boolean restart ) { } public void stop ( ) { } public void shutdown ( ) { } void respawn ( ) { } private final class JoinTask implements Runnable { private final long startTime ; public JoinTask ( final long startTime ) { } public void run ( ) { final Process process ; synchronized ( lock ) { process = ManagedProcess . this . process ; } int exitCode ; for ( ; ; ) try { exitCode = process . waitFor ( ) ; log . processFinished ( processName , Integer . valueOf ( exitCode ) ) ; break ; } catch ( InterruptedException e ) { } boolean respawn = false ; boolean slowRespawn = false ; boolean unlimitedRespawn = false ; int respawnCount = 0 ; synchronized ( lock ) { final long endTime = System . currentTimeMillis ( ) ; processController . processStopped ( processName , ( endTime - ( startTime ) ) ) ; state = ManagedProcess . State . DOWN ; if ( shutdown ) { processController . removeProcess ( processName ) ; } else if ( ( isPrivileged ( ) ) && ( exitCode == ( ExitCodes . HOST_CONTROLLER_ABORT_EXIT_CODE ) ) ) { if ( ( processController . getOngoingProcessCount ( ) ) > 1 ) { respawn = true ; respawnCount = ManagedProcess . this . incrementAndGetRespawnCount ( ) ; unlimitedRespawn = true ; slowRespawn = true ; } else { processController . removeProcess ( processName ) ; new Thread ( new Runnable ( ) { public void run ( ) { processController . shutdown ( ) ; <START_BUG> System . exit ( 0 ) ; <END_BUG> } } ) . start ( ) ; } } else if ( ( isPrivileged ( ) ) && ( exitCode == ( ExitCodes . RESTART_PROCESS_FROM_STARTUP_SCRIPT ) ) ) { processController . removeProcess ( processName ) ; new Thread ( new Runnable ( ) { public void run ( ) { processController . shutdown ( ) ; System . exit ( RESTART_PROCESS_FROM_STARTUP_SCRIPT ) ; } } ) . start ( ) ; } else { if ( ! ( stopRequested ) ) { respawn = true ; respawnCount = ManagedProcess . this . incrementAndGetRespawnCount ( ) ; if ( ( isPrivileged ( ) ) && ( ( processController . getOngoingProcessCount ( ) ) > 1 ) ) { unlimitedRespawn = true ; } } } stopRequested = false ; } if ( respawn ) { respawnPolicy . respawn ( respawnCount , ManagedProcess . this , slowRespawn , unlimitedRespawn ) ; } } } private final class ReadTask implements Runnable { private final InputStream source ; private final PrintStream target ; private ReadTask ( final InputStream source , final PrintStream target ) { } public void run ( ) { final InputStream source = this . source ; final String processName = ManagedProcess . this . processName ; try { final BufferedReader reader = new BufferedReader ( new InputStreamReader ( new BufferedInputStream ( source ) ) ) ; final OutputStreamWriter writer = new OutputStreamWriter ( target ) ; String s ; String prevEscape = "" ; while ( ( s = reader . readLine ( ) ) != null ) { int i = s . lastIndexOf ( '' ) ; int j = ( i != ( - 1 ) ) ? s . indexOf ( 'm' , i ) : 0 ; synchronized ( target ) { writer . write ( '[' ) ; writer . write ( processName ) ; writer . write ( "]<seq2seq4repair_space>" ) ; writer . write ( prevEscape ) ; writer . write ( s ) ; if ( ( j != 0 ) || ( prevEscape != "" ) ) { writer . write ( "[0m" ) ; } writer . write ( '\n' ) ; writer . flush ( ) ; } if ( j != 0 ) { String escape = s . substring ( i , ( j + 1 ) ) ; if ( ! ( "[0m" . equals ( escape ) ) ) { prevEscape = escape ; } else { prevEscape = "" ; } } } source . close ( ) ; } catch ( IOException e ) { log . streamProcessingFailed ( processName , e ) ; } finally { StreamUtils . safeClose ( source ) ; } } } }

Fix:
System . exit ( NORMAL ) ;