Mountain Lion

Peter Korsten peter at severity-one.com
Sun Feb 19 16:36:45 CET 2012


Hi Martin,

>> But in my scenario, where a process detaches itself from the terminal it
>> was started from, is it possible to do something similar with Windows?
>
> Yes, there are indeed flags and options to handle terminal windows -
> e.g. creating a new one for the process. You can also just run a "Win32"
> style app that doesn't connect to a terminal at all. I don't remember
> the details from the top of my head as it's been ages since I needed
> something similar.
>
> But if you want a deamon, you should really look into the services concept.

Fair enough.

>> The impression I get is that you need to add certain flags to the
>> CreateProcess call, but that would make the solution actually more
>> complex that the Unix one.
>
> It certainly is - but the big question remains why you want this in the
> first place instead of running a multi-threaded app.

The point is start-up. A Java process that does backend-y stuff is 
started from a command line or startup script, and therefore always hogs 
the terminal (or script) it was started from. You can always apply some 
flags to redirect output and error streams, and start it in the 
background, but it would be much more elegant to have it start as a daemon.

For Unix, I managed and it's in fact remarkably easy, just a few lines 
of code. But I think that my mistake is trying to fit a Unix concept (a 
daemon) to Windows, which is just not a good idea.

Not that it matters much; we don't run anything server-like on Windows 
boxes (except Siebel), so there's no real need. But what I like about 
Java is that it runs everywhere, so I would like the same capability on 
all platforms the code might run on. Our development all takes place on 
Windows 7 boxes, after which it gets deployed on virtualised Solaris x64 
boxes.

- Peter


More information about the music-bar mailing list