Subject: Using Cygwin to build a system service under NT
From: [email-masked] (Shankar Ramamoorthy)

7 Mar 1997 20:42:19 -0800
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
Original-To: [email-masked]
X-Sun-Charset: US-ASCII
Original-Sender: [email-masked]

Has anyone used cygwin to build a system service under NT? I am
having the following problem, after I built my system service:

: It installs fine and I can start the service from the Service Controller
: Once it is started, I cannot run ANY cygwin program. I get the foll.
  error:
  (unknown) shared_init: CreateFileMappingA
  cygwin: terminating

: I believe it is working fine - I just cannot launch another cygwin
  program while it is running.

: If I stop the service from the Service Controller and run the
  service program as a console app (debug mode), everything is fine.

I have the exact same problem if I launch a cygwin built console app
from a system service program built using MSVC. What am I doing wrong?

I've attached snippets of the system service functions and would be
happy to mail a simple test case (the Simple Service program that
comes with MSVC)  which demonstrates the problems, if
someone wants it. It's about 1k lines.

Thanks a lot,

Shankar
[email-masked]

---
    SERVICE_TABLE_ENTRY dispatchTable[] =
    {
        { TEXT(SZSERVICENAME), (LPSERVICE_MAIN_FUNCTION)service_main },
        { NULL, NULL }
    };
---
        if (!StartServiceCtrlDispatcher(dispatchTable))
            AddToMessageLog(TEXT("StartServiceCtrlDispatcher failed."));
---
    sshStatusHandle = RegisterServiceCtrlHandler( TEXT(SZSERVICENAME), service_ctrl);

---
        schService = CreateService(
            schSCManager,               // SCManager database
            TEXT(SZSERVICENAME),        // name of service
            TEXT(SZSERVICEDISPLAYNAME), // name to display
            SERVICE_ALL_ACCESS,         // desired access
            SERVICE_WIN32_OWN_PROCESS,  // service type
            SERVICE_DEMAND_START,       // start type
            SERVICE_ERROR_NORMAL,       // error control type
            szPath,                     // service's binary
            NULL,                       // no load ordering group
            NULL,                       // no tag identifier
            TEXT(SZDEPENDENCIES),       // dependencies
            NULL,                       // LocalSystem account
            NULL);                      // no password
---
-
For help on using this list, send a message to
"[email-masked]" with one line of text: "help".