Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Send signals to processes

Reply
Thread Tools

Send signals to processes

 
 
diho@ba-horb.de
Guest
Posts: n/a
 
      02-19-2004
Hello,

I start a process with the "Runtime.getRuntime.exec("...")" command
and like to send a signal to this process. How can I do this, since
java.lang.Process does not provide an apropriate method ?
Is there any alternative to the "exec"-command to execute commands ?

Thanks for help,
diho
 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      02-19-2004
On 19 Feb 2004 06:46:45 -0800, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hello,
>
> I start a process with the "Runtime.getRuntime.exec("...")" command
> and like to send a signal to this process. How can I do this, since
> java.lang.Process does not provide an apropriate method ?
> Is there any alternative to the "exec"-command to execute commands ?


There is no alternative. You can have the child process tell you its
pid though, and use that to send it signals. For example you can use a
runner script like this one to get the pid of any process you run with
Runtime.exec():

#!/bin/sh

echo $$
exec "$@"


Now do this to run "myprog":

Runtime.getRuntime().exec("runner myprog arg1 arg2");

and read the pid as the first line of output.

To send a signal to the process, use something like this:

Runtime.getRuntime().exec("/bin/kill -INT " + pid);

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Traping signals on child processes Mário Lopes Ruby 12 06-03-2008 04:12 PM
Questions about perl daemons with child processes and open files / signals none Perl Misc 9 04-08-2006 09:02 PM
help with concurrency control (threads/processes & signals) Sori Schwimmer Python 1 10-27-2005 05:37 PM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM
write signals at different processes default VHDL 3 10-24-2003 07:29 PM



Advertisments