|
From: Konrad H. <ko...@pa...> - 2012-11-14 11:34:54
|
> -----Original Message----- > From: Robert Latest [mailto:bob...@gm...] > Sent: Sunday, November 11, 2012 1:57 PM > To: MinGW Users List > Subject: [Mingw-users] How to write a "proper" Win32 daemon using MinGW? > > Hello all, > > I'd like to know if it is at all possible to write UNIX-like daemons > in a MinGW (non-MSYS) environment. Of course I could just go ahead and > try to cook something that fork()s off and does its thing in the > background, but I'd like to know if it works on Windows just as on > Linux. On startup, the program must check if another instance is > already running, and must abort. Alternatively, when called a second > time with a command-line option, it must cause the existing process to > cleanly terminate. Robert -- I've been watching this thread in anticipation of learning a new trick that I could accomplish with MSys/MinGW that also runs on Linux. Alas, no joy <G>. I have written and compiled several Portable Linux Daemons that also run as Windows Services using Active State's PDK. Starting as a single perl-script which is compiled to a.exe for Windows or an elf binary for Linux, Active State perl is the most portable and 'UNIX-like' method I have yet found (<G> but I am still looking <G>). > Since all the program does is a periodic consistency check of a bunch > of files once a minute, writing out the result in another file, it is > trivial to just have a batch file call the program in an infinite > loop. This is what I'll do for the first testing version. Eventually I > would like the thing to run invisibly in the background without > littering the task bar with nonsensical command windows though. This is something that Perl could do very well. Maybe take a look at perl as included with MSys / MinGW ? If you need to compile the code, Active State Perl is 'one way to do it'. -- kjh(<G> I don't work for Active State, nor do I own any stock <G>) |