Jim Kimball wrote:
>
> Dustin -
>
> This sounds to me like an environment issue. On Win NT, 98, Unix bash
> and c-shell, this is the default behavior I have seen.
>
> I say it may be an environment issue because I recall from working with
> the Bourne shell that exec'd processes are killed when the parent
> process exits, while processes exec'd in C shell are not.
The issue is how to detach a process from its parent's process group,
much like like daemons do when you start them up. It's easy in C; the
call is setpgid(0). To make a C application behave completely like a
daemon, try this early in main():
setpgid(0);
/* Spawn a child */
pid_t result = fork();
/* Complain if we failed */
if (result == -1) { ...puke and complain... }
/* Terminate if we're the parent */
if (result > 0) return 0;
/* Continue running if we're the child */
The process has terminated (as far as the invoker is concerned) but
continues to go its merry way. You may need to experiment with the best
place to call setpgid().
So... getting back to the original problem, you might want to put this
code into the application you're starting. And if you don't have access
to that, you can create a separate program that will essentially make
your application a daemon: a trivial program that runs the above code
followed by an exec() of the application you really want to run.
Nathan
> Dustin Lang wrote:
> >
> > Hi,
> >
> > Can anyone tell me if there is a way to Runtime.exec() a process that
> > lives longer than the Java process that spawns it?
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]