On Sun, Aug 27, 2000 at 02:05:07PM -0400, Andrew Majercik wrote:
>   Applications "tie" themselves to the console window in a parent/child
> relationship. (once the parent goes away, so do all the children!) What you 

Actually, they are tied to the process which spawned them (typically
the shell). It' a subtle difference.

> need to do is detach the process from the terminal.  One way of doing this 
> is to run it as a daemon (if there are other ways, I do not know them ), 
> which essentially forks a process(which copies the process), and exits that 
> process, leaving a detached child process(your java app, in this
> case).   It 

This can be done with a simple shell script.

> is somewhat of a nuiscance to do from within java, since you'll need to make 
> a native call to do so. (going through JNI).
> The native portion is only about 6 lines long, and good unix book should be 
> able to tell you how to do that.   I suppose you could avoid the JNI call 
> altogether by writing a native program that could daemonize any program, and 
> then calling your program from it via command line.  I"ve done both, the JNI 
> call is a bit cleaner, since it ends up using only one process.

There's another reason not to do this from within Java. If you are
using a VM with native threads, then you are going to be forking a
process with multiple threads. The semantics for how this is done
varies from one system to another, and IMHO Linux's approach is no
better than any of the others. I find it better to avoid the whole
mess by doing all my forks before I spawn threads.

--Chris


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to