From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18817 invoked by alias); 15 Nov 2001 11:10:21 -0000 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@sources.redhat.com Received: (qmail 18777 invoked from network); 15 Nov 2001 11:10:15 -0000 Received: from unknown (HELO mailsrv.s3group.com) (193.120.90.35) by sourceware.cygnus.com with SMTP; 15 Nov 2001 11:10:15 -0000 Received: from headyin.s3group.com (headyin.s3group.com [193.120.89.200]) by mailsrv.s3group.com with ESMTP id fAFB83728403; Thu, 15 Nov 2001 11:08:03 GMT Received: from s3group.com ([193.120.88.174]) by headyin.s3group.com (Sun Internet Mail Server sims.4.0.2000.10.12.16.25.p8) with ESMTP id <0GMU003L79OZXP@headyin.s3group.com>; Thu, 15 Nov 2001 11:10:11 +0000 (GMT) Date: Sun, 11 Nov 2001 08:26:00 -0000 From: JAmes Coleman Subject: Re: Win98se and using SSHD as a TRUE service To: Gerald Villemure Cc: cygwin@cygwin.com Message-id: <3BF3A48E.9537B5DD@s3group.com> MIME-version: 1.0 X-Mailer: Mozilla 4.73 [en] (WinNT; I) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT X-Accept-Language: en References: <3BF274A3.D7E5F5DA@s3group.com> <00c901c16d7b$da23f880$0200000a@dyn.ik.ca> X-SW-Source: 2001-11/txt/msg00274.txt.bz2 Hi Gerald, Gerald Villemure wrote: > > The idea here is to have SSHD start as a true service in Win9x such that it > will NOT dies when a user logs out. To do this the process must make the > system call "RegisterServiceProcess" which only exist in Win95, Win98 and > WinMe. > > James Coleman: I tryied adding the #include "windows.h" line but I still > have compile errors: > > $ make > gcc -g -O2 -Wall -Wpointer-arith -Wno-uninitialized -I. -I.. -I. -I./.. -DH > AVE_CONFIG_H -c daemon.c > daemon.c: In function `daemon': > daemon.c:67: parse error before `kerneldll' > daemon.c:68: `kerneldll' undeclared (first use in this function) > daemon.c:68: (Each undeclared identifier is reported only once > daemon.c:68: for each function it appears in.) > daemon.c:72: parse error before `(' > daemon.c:73: `RegisterService' undeclared (first use in this function) > daemon.c:79: `RegisterService' used prior to declaration > daemon.c:79: warning: implicit declaration of function `RegisterService' > make: *** [daemon.o] Error 1 I had a go at compiling what you sent, obviously I can't compile it properly but I can test the syntax anyway. I just had to remove #include "includes.h" For me, gcc version 2.9-cygwin-990830, I got similar errors to you and others which I got rid of by fixing includes ... (except for one). daemon.c: In function `daemon': daemon.c:82: parse error before `kerneldll' daemon.c:83: `kerneldll' undeclared (first use in this function) daemon.c:83: (Each undeclared identifier is reported only once daemon.c:83: for each function it appears in.) daemon.c:87: parse error before `(' daemon.c:88: `RegisterService' undeclared (first use in this function) daemon.c:95: `RegisterService' used prior to declaration daemon.c:95: warning: implicit declaration of function `RegisterService' daemon.c:108: `_PATH_DEVNULL' undeclared (first use in this function) (I add the following includes) //#include #include #include #include #include #include #define HAVE_CYGWIN ANYWAY Two things .... (possibly caused by command line options?) 1. compiler doesn't like // comments 2. compiler doesn't like declaration of variables except at start of function The following compiles okay for me (with only the one error I introduced which you shouldn't have) int daemon(nochdir, noclose) int nochdir, noclose; { int fd; HINSTANCE kerneldll; DWORD (*RegisterService)(DWORD, DWORD); switch (fork()) { case -1: return (-1); case 0: break; default: #ifdef HAVE_CYGWIN /* * This sleep avoids a race condition which kills the * child process if parent is started by a NT/W2K service. */ sleep(1); /* * This is the code that I took from WinVNC * The best solution would be to enclose this in a IF Win9x clause * that is if I knew propers C syntax I could do this */ /* Obtain a handle to the kernel library */ kerneldll = LoadLibrary("KERNEL32.DLL"); if (kerneldll == NULL) break; /* And find the RegisterServiceProcess function */ RegisterService = (DWORD (*)(DWORD, DWORD)) GetProcAddress(kerneldll, "RegisterServiceProcess"); if (RegisterService == NULL) break; /* Register this process with the OS as a service! */ RegisterService(NULL, 1); #endif _exit(0); } if (setsid() == -1) return (-1); if (!nochdir) (void)chdir("/"); if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { (void)dup2(fd, STDIN_FILENO); (void)dup2(fd, STDOUT_FILENO); (void)dup2(fd, STDERR_FILENO); if (fd > 2) (void)close (fd); } return (0); } > > The source is at the end of this email. > > The problem may be easy to spot but its beyond me. I can help a bit with C and a little with cygwin but I don't do all that much cygwin+windows programming. Hopefully this is useful. > > I am trying to fix the right file for this right? :) That's a very good question .... and I really don't know the answer to it :-7 Last time I played with services was on msdos5.something! > > Thanks for any help, > GĂ©rald > Good Luck! JAmes. -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/