
Signature
Esben Stien is b0ef@e s a
http://www. s t n m
irc://irc. b - i . e/%23contact
sip:b0ef@ e e
jid:b0ef@ n n
>> $ nohup java MyApp > /dev/null 2>&1 &
>
> No. This is not what I'm looking for. This is a hack. I want the
> application to detach cleanly like a normal daemon.
>
> Thank you for your help so far, but this is not the correct way;).
A daemon changes its working directory, forks, redirects output
streams to /dev/null, detaches from the controlling terminal by
calling setsid(), and forks again. You'll be hard pressed to
accomplish most of that in Java.
Perhaps what you want is this instead:
$ setsid java MyApp > /dev/null 2>&1 &
or
$ ( setsid java MyApp > /dev/null 2>&1 & ) &
to get the extra fork.
If that isn't "clean enough" for you, then you need to write your own
Java launcher in C.
/gordon

Signature
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Domagoj Klepac - 28 Aug 2006 21:44 GMT
>> No. This is not what I'm looking for. This is a hack. I want the
>> application to detach cleanly like a normal daemon.
[quoted text clipped - 5 lines]
>calling setsid(), and forks again. You'll be hard pressed to
>accomplish most of that in Java.
When it comes to Java daemons/services:
http://wrapper.tanukisoftware.org/
Domchi