!747 m { static int masterPort; static DialogIO masterConn; static int interval = 1000; p { masterPort = parseInt(args[0]); masterConn = talkTo("localhost", masterPort); print("Dependent VM: Connected to master at port " + masterPort + "."); masterConn.readLine(); masterConn.sendLine("Master: My VM port is " + myVMPort()); masterConn.readLine(); while (shouldStayAlive()) sleep(interval); System.exit(0); } static boolean shouldStayAlive() { try { masterConn.sendLine("Master: Should I stay alive?"); S answer = masterConn.readLine(); boolean yes = match3("yes", answer) || match3("yes ...", answer); if (!yes) print("Master said: " + answer); return yes; } catch (Exception e) { e.printStackTrace(); return false; } } }