Involuntary forking (cloing) of win32/64 app

Yep, you read correcly, my app is spontaneously forking itself - in windows.

I've written a command-line native C++ app with VS2008 to measure temperature data using a Dallas Semiconductors 1-wire hardware and storing the data in a MySQL server. No .NET stuff. For this I use the Dallas Semiconductors TMEX SDK (link below) and the MySQL C++ connector.

My app is strictly command-line, is run with scheduler once every minute, and exits normally after a second or so. Most of the time, 98% of runs, everything is fine - no error messages, data stored correcly and all that. But sometimes, about once every hour (though not consistently) the app splits in two (or is possibly run twice). I have included some simple logging of key events in the app, storing them in a textfile along with the process ID, and they are indeed different. It LOOKS like the app is simply started twice, almose simultaneously, each process doing it's work correcly and then exiting. The temperature hardware cannot be shared, so one of the threads pauses to let the outher one finish, and then carries on itself. Still no error messages, and nothing in windows logs. The temperature data is simply measured and stored twice. I use the simpliest of C++ language, no threading, no registering of windows classes, nothing. I DO use LoadLibrary to import a DLL for hardware access, and GetCurrentProcessID for logging, but no other WINAPI functions I can think of. Other than the ones used by the MySQL C++ Connector, of course.

What about the scheduler then? Well, I've tried both windows scheduler and an old one I made myself back in the days when the built in windows scheduler couldn't do work once every minute. Same result, except that my own scheduler seems to give the error slightly more often, and more erradic. I run the app using CMD.EXE /C [myapp.exe] [my_args]

The behaviour is identical on two servers, a Windows 2008 R2 x64 on dual-core CPU, and a Windows 2003 original x86 on single core x64 CPU. The former runs a 64 bit version of the app (with a 64-bit DLL), and the latter of course a 32-bit version.

Has anyone dealt with anything similar? Where do I need to look? Anyone seriously interested in helping out please mail me for source code.

Best regards
Måns

TMEX SDK: http://files.dalsemi.com/auto_id/softdev/owdocs_400beta2/Docs/1-Wire_SDK_Help.html
Last edited on
Topic archived. No new replies allowed.