I run process on unix through runtime.exec() method.
But my process termintaes before chid process terminates.
How can I trap that child process termination.
The process.waitfor method block for while until the process terminates..
Can anyone tell me how can I get process information randomly until the main process terminates and it's child processes also throgh java..
Plz send me the solution immediately
2 2233
If you need a Java answer then I'd ask in the Java board, otherwise, I can only give a C answer after I look up a detail I forgot.
horace1 1,510
Recognized Expert Top Contributor
I run process on unix through runtime.exec() method.
But my process termintaes before chid process terminates.
How can I trap that child process termination.
The process.waitfor method block for while until the process terminates..
Can anyone tell me how can I get process information randomly until the main process terminates and it's child processes also throgh java..
Plz send me the solution immediately
this starts a child process and receives and displays its output - is that what you require? -
// execute a child process using java exec command and get output
-
-
import java.io.*;
-
import java.lang.*;
-
-
public class JavaExec {
-
-
public static void main (String args[]){
-
try {
-
// get runtime environment and execute child process
-
Runtime systemShell = Runtime.getRuntime();
-
Process output = systemShell.exec("java -jar hello.jar");
-
// open reader to get output from process
-
BufferedReader br = new BufferedReader (new InputStreamReader(output.getInputStream()));
-
String line = null;
-
System.out.println("<OUTPUT/>");
-
while((line = br.readLine()) != null )
-
{ System.out.println(line); } // display process output
-
System.out.println("</OUTPUT>");
-
int exitVal = output.waitFor(); // get process exit value
-
System.out.println("Process Exit Value : "+ exitVal);
-
}
-
catch (IOException ioe){ System.err.println(ioe); }
-
catch (Throwable t) { t.printStackTrace();}
-
}
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Clive Everett |
last post by:
I thought it would be rather fun to try out @font-face, but I cannot get it
to work.
I used Microsoft WEFT to generate several embedded fonts and find that the
example
below works when I use my Win XP development machine as both the browser and
Web
server. However if I try to display the same page from another machine (Mac
OS X, Win 2000, or Win XP) using the Win XP development machine as the Web
server then I get the default font...
|
by: B Wooster |
last post by:
There is a page that shows Firefox 1.0 render text differently for CSS
as compared to FONT FACE for one particular font:
http://www.aczoom.com/fonts/xdvng.ttf is the font that does not work.
http://www.aczoom.com/isongs/0/t_ff.html
is the test page - that has shows the line "This is using CSS to
specify xdvng:" show up with the default english font instead of
xdvng.
Internet Explorer works as expected - both CSS and FONT FACE use of
|
by: felixfix |
last post by:
Hi all,
I am just wondering if something is wrong with my program. What it
bascially does is to output a fibonacci sequence base on the
command-line output. If I give a 5, it will generate the first 5
fibonacci number. The problem is, I thought the parent process will
always go first, and so here I should get "0, 1, 1, 2, 3" But I ran the
program, it will give me "1, 2, 3, 0, 1", which is, the child process
ran first. Is there any way...
|
by: Gabe Moothart |
last post by:
Hi,
I'm writing a windows service which interacts with a separate process.
Basically, it calls a process which creates a file, and then my service
reads that file. The problem is, the external process can take a second
or two to finish writing the file. If I try to read the file to soon, I
get an exception that "The process cannot access the file because it is
being used by another process".
I could just set a timer, but the time it...
|
by: ML |
last post by:
We have a large batch type update process that the user needs to launch from
a button on an ASP.NET webpage. The process basically does some queries
against SQL Server, loops through the result set, and process the data and
inserts new data to the database.
The problem is that this process can take several minutes to run due to the
amount of data being handled. Because of this if the user closes the
webpage or goes back to a previous...
| |
by: Jag Chat via .NET 247 |
last post by:
I would like to call a .NET executable file in a windows serviceat certain intervals of time. The following is the codesnippet, I put in. I am not receiving any error in my errorhandling routine (as it writes as a log entry). But my problemis, the respective application doesn't popup on screen and getvisible. I desperately need the application to be visible whenit does some work (just to know basically the status andprogress of the process...
|
by: Zen |
last post by:
Hi,
My production machine has 2G of memory, when aspnet_wp.exe goes up to about
~1.2G of memory usage, I start get out-of-memory exception. Other processes
don't use as much memory and I added all the peak memory usage of all the
processes (including aspnet_wp.exe), it goes up to no more than 1.5.
How is that possible? Would anyone know please help? thanks!
|
by: Hamed |
last post by:
Hello
Is it possible to get a control (e.g. a checkbox) and make a Graphics object
or a Bitmap object of current face of the control?
I want to implement Sparse property for a ColumnStyle so I need above
functionality.
Regards
|
by: bayer.justin |
last post by:
Hi,
I am trying to communicate with a subprocess via the subprocess
module. Consider the following example:
<subprocess.Popen object at 0x729f0>
Here hey is immediately print to stdout of my interpreter, I did not
type in the "hey". But I want to read from the output into a string,
so I do
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |