Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Running the process even after the program quits!  RSS feed

 
prashant pachouri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!
I am facing a real life trouble here..
from my program I want to initiate some processes which should continue even after my program which started them goes off
In short,
I want to achieve something like this
public class Launcher{
main(){
Runtime.getRuntime().exec("java -cp cpofMyClasspFile MySocketServerClass");
}
}
now when I do a ^c on the command prompt to terminate the Launcher My socket server program also goes off can I achieve it some way.. I thought this has got something to do with daemon threads
Thanks a lot!
pach

------------------
If you are not living on the edge, you are wasting Space.
 
Yuri Gadow
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is going to be OS dependant. I don't know how to accomplish this under windows without using a service, in *nix you'll be looking a variety of options. Suffice it to say, you're going to be depending on the tools provided by the OS to do background processes.
Daemon threads are related to VM shutdown only in that they do not prevent it. In other words, a VM will exit even if there are threads set daemon currently running, where normally it would not if a non-daemon thread was alive. When the VM shuts down, the threads go as well, daemon or otherwise.
 
prashant pachouri
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Yuri,

Could you give me some I Idea on how to achieve this on unix.
 
Michelle Baxter
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't tried this, but to run a UNIX command from a window and have it continue after logging out or killing the window, try the nohup command. You should be able to do a man on it, or type nohup --help. Let me know if it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!