213 System.out.println("Running Runtime.getRuntime.halt");
214 Runtime.getRuntime().halt(17);
215 }
216
217 @Override
218 public void verifyEvents(RecordedEvent event, int exitCode) {
219 Events.assertField(event, "reason").equal("Shutdown requested from Java");
220 validateStackTrace(event.getStackTrace());
221 }
222 }
223
224 private static class TestSig implements ShutdownEventSubTest {
225
226 private final String signalName;
227
228 @Override
229 public int attempts() {
230 if (Platform.isWindows()) {
231 return 0;
232 }
233 if (signalName.equals("HUP") && Platform.isSolaris()) {
234 return 0;
235 }
236 return 1;
237 }
238
239 public TestSig(String signalName) {
240 this.signalName = signalName;
241 }
242
243 @Override
244 public void runTest() {
245 System.out.println("Sending SIG" + signalName + " to process " + ProcessHandle.current().pid());
246 try {
247 Runtime.getRuntime().exec("kill -" + signalName + " " + ProcessHandle.current().pid()).waitFor();
248 Thread.sleep(60_1000);
249 } catch (InterruptedException e) {
250 e.printStackTrace();
251 } catch (IOException e) {
252 e.printStackTrace();
253 }
254 System.out.println("Process survived the SIG" + signalName + " signal!");
255 }
|
213 System.out.println("Running Runtime.getRuntime.halt");
214 Runtime.getRuntime().halt(17);
215 }
216
217 @Override
218 public void verifyEvents(RecordedEvent event, int exitCode) {
219 Events.assertField(event, "reason").equal("Shutdown requested from Java");
220 validateStackTrace(event.getStackTrace());
221 }
222 }
223
224 private static class TestSig implements ShutdownEventSubTest {
225
226 private final String signalName;
227
228 @Override
229 public int attempts() {
230 if (Platform.isWindows()) {
231 return 0;
232 }
233 return 1;
234 }
235
236 public TestSig(String signalName) {
237 this.signalName = signalName;
238 }
239
240 @Override
241 public void runTest() {
242 System.out.println("Sending SIG" + signalName + " to process " + ProcessHandle.current().pid());
243 try {
244 Runtime.getRuntime().exec("kill -" + signalName + " " + ProcessHandle.current().pid()).waitFor();
245 Thread.sleep(60_1000);
246 } catch (InterruptedException e) {
247 e.printStackTrace();
248 } catch (IOException e) {
249 e.printStackTrace();
250 }
251 System.out.println("Process survived the SIG" + signalName + " signal!");
252 }
|