/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4763384
* @summary Ensure that piped input always works with exec'd processes
*/
/**
* This class demonstrates a regression in java1.4.1 in the handling of the
* Process OutputStream (exec'd process stdin). The subprocess completes 100%
* of the time in 1.4, but about only about 50% of the time under 1.4.1. Issue
* exists for client JVM, Linux Redhat 6.2 not sure about other variants of
* Linux or other OSes, or server JVM.
*/
public class ExecWithInput {
private static final int N = 200;
/*
* read the input lines and copy them to stdout. On completion,
* p.waitFor should return and the exit status is printed and this
* program exits. Under 1.4.1, cat sometimes gets stuck on a pipe
* read and never terminates.
*/
//Process p = Runtime.getRuntime().exec(new String[] { CAT } );
// create threads to handle I/O streams
// wait for process to exit
return p.waitFor();
}
return;
return;
}
for (int i = 0; i < N; i++)
go(i);
}
/**
* Handle IO. Thread is started in constructor.
*/
{
start();
}
public void run() {
try {
int c;
byte[] buf = new byte[8192];
int n;
}
/*
while ((c = in.read()) != -1) {
out.write(c);
if (c == '\n')
out.flush();
}
out.flush();
*/
} catch (IOException e) {
e.printStackTrace();
} finally {
// Note: in order to get an exec'd java process to
// see EOF on input, it is necessary to close stdin
e.printStackTrace();
}
}
}
}
}
}
}