01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.process;
05:
06: import java.io.File;
07: import java.io.FileOutputStream;
08: import java.io.PrintStream;
09:
10: /**
11: * A test program for {@link LinkedJavaProcessTest}that, in turn, spawns some of its own children as linked processes.
12: * The test then kills this process, and makes sure that the children die, too.
13: */
14: public class LinkedJavaProcessTestMain5 {
15:
16: public static void main(String[] args) throws Exception {
17: File destFile = new File(args[0]);
18: boolean spawnChildren = new Boolean(args[1]).booleanValue();
19:
20: if (spawnChildren) {
21: LinkedJavaProcess child1 = new LinkedJavaProcess(
22: LinkedJavaProcessTestMain5.class.getName(),
23: new String[] { args[0] + "-child-1", "false" });
24: LinkedJavaProcess child2 = new LinkedJavaProcess(
25: LinkedJavaProcessTestMain5.class.getName(),
26: new String[] { args[0] + "-child-2", "false" });
27: child1.start();
28: child2.start();
29: }
30:
31: File stdoutFile = new File(destFile + ".stdout.log");
32: System
33: .setOut(new PrintStream(
34: new FileOutputStream(stdoutFile)));
35:
36: long start = System.currentTimeMillis();
37: while (System.currentTimeMillis() - start < 3 * 60 * 1000) {
38: FileOutputStream out = new FileOutputStream(destFile, true);
39: out.write("DATA: Just a line of text.\n".getBytes());
40: out.flush();
41: out.close();
42:
43: Thread.sleep(100);
44: }
45: }
46:
47: }
|