Mountain Lion

Peter Korsten peter at severity-one.com
Fri Feb 17 21:48:13 CET 2012


Op 17-2-2012 20:56, Paul Maddox schreef:

>> And as for a nice operating system, there's always Windows 7. My impression is that it is slightly less stable than XP (I don't remember ever getting a BSOD with XP, whilst I've had a couple with 7, though usually whilst gaming and perhaps it's a hardware issue), but it's rather nice to use.
>
> Windows 7, agreed not good.

Hmmm, I actually quite like Windows 7. All in all, it's stable - just 
slightly less so than XP. I'm trying to remember if I ever had a BSOD at 
work.

Recently, I changed my ageing and dusty graphics card to a snazzy new 
one, which should help stability as well. I was getting some weird 
behaviour with that old card towards the end...

> Windows Vista is actually pretty good, what I've seen and used of it, but I wouldn't buy it :)

I think Vista sucks. Windows 7 is what Vista should have been in the 
first place.

>> Developing for it, now that's a different issue. I built a small demonstration program today, where a Java process detaches itself from the Unix shell by invoking fork() via JNA, but I have no idea how such a thing could be done with Windows. Windows development has always struck me as just a bit too complex to get your head around.
>
> see, you lost me there with "fork" :)

Go to one of your Linux boxes and type 'man fork'.

Calling the fork() function will duplicate the current process. You 
could use is to do some primitive kind of multi-tasking, although these 
days you'd use lightweight threads for that.

The fork() function returns a process ID (pid_t). If it is 0, the 
current process is the child process. If it is not 0, it's the process 
ID of the child process, and you're in the parent process. Remember, you 
just created a parallel universe for your process, so in one parallel 
universe you get a different return value than in the other one.

If you then exit the parent process, and close stdout and stderr (and 
possibly stdin as well) in the child process, you've detached the 
process from the terminal, so that it runs in the background. This is 
how most daemons in Unix work.

Something like this:

     int main( int argc, char** argv )
     {
         if( !fork() )
            return 0;

         fclose( stdout );
         fclose( stderr );

         /* Do daemony stuff here */
     }

I was trying to figure out how to do that in Windows, but so far haven't 
found out how. Possibly, it depends on process startup flags, which 
means you'd have to do something similar to what you do in Unix.

- Peter


More information about the music-bar mailing list