Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running the process even after the program quits!

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Yuri,

Could you give me some I Idea on how to achieve this on unix.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
It runs on an internal combustion engine. This ad does not:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic