|Index Nav:||[Date Index] [Subject Index] [Author Index] [Thread Index]|
|Message Nav:||[Date Prev] [Date Next]||[Thread Prev] [Thread Next]|
I'm trying to use the Cynus stuff to write an NT service and am running into a couple problems. The first is that fork() doesn't work from an NT Service, the second is that cygwin_winpid_to_pid() doesn't seem to work properly. I'm using NT4 Workstation, service pack 3 Attached (I hope!) is a .zip file that contains a modified version of the "simple service" sample that ships with Microsoft's Developer Studio. I've changed it so that about all it does is fork()/exec() the notepad application and then wait to be killed. Everything works great when running the service in debug mode (starting it with -debug argument) but the fork fails when the service is started from the services control panel. I catch the following on stderr when the problem occurs: [unknown (0xA1)] forktest 1349 (1) sync_with_child: child 100(0x84) died before initialization with status code 0xC00000FD [unknown (0xA1)] forktest 1349 (0) sync_with_child: *** child state waiting for longjmp I would happily forget about the fork() bug and just use the native CreateProcess() API but the service needs to kill its children when it dies and I can't use kill() to send SIGTERM because I can't get a cygwin pid from a win pid: cygwin_winpid_to_pid() returns -1 for the pid of the process I created with CreateProcess(), even if it shouldn't. By shouldn't I mean I can do a "ps" in a shell and the process I created is shown there. The attached sample demonstrates this problem as well, I do a CreateProcess() on cygwish80.exe. About the sample: - no makefile, to build I just do a "gcc -o forktest *.c" and that works fine - when running as an NT Service it writes stderr to /tmp/forktest_stderr, better make sure /tmp exists before running - once compiled, the service is "installed" by running it with a "-install" argument , uninstalled by running it with a "-remove" argument, and run in debug mode by giving it a "-debug" argument. - while running in debug mode the service can be stopped by sending it a CTRL-C - the StartProcess* functions in the simple.c module contain hard-wired paths to cygwish80 and notepad. they will probably need to be changed in order to run on computers other than mine.
-- Want to unsubscribe from this list? Send a message to firstname.lastname@example.org