Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Reply-To: From: "John Ypsilantis" To: Subject: Shmget() fails when run within a program that is started by inetd. Has anyone else encountered this? Date: Sat, 2 Jul 2005 23:52:34 +1000 Message-ID: <000001c57f0d$4f5ca060$1100a8c0@delfin> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I have come across what may be a problem with the interaction of the shared memory subsystem with networking code that is run up by inetd. The following program runs to completion when started interactively and under (x)inetd control for FC3. While it also runs to completion when started interactively under Cygwin, it crashes silently within the shmget() call when it is run up under inetd. The program should be run on a system with shared segment with key=1 absent. ------------------------------------------------------------------------ ------------------ Code ------ (filename: testseg.c, compile as a standalone) #include #include /* use for FC3 */ #include /* use for FC3> int main() { int segid; /* segment ID */ struct shseg *ptr; /* dereference the segment */ /* Attach to the shared segment as read-only, fail if segment not present */ fprintf(stdout, "About to call shmget()\n"); fflush(stdout); segid = shmget(1, 1024, SHM_R); /* Process dies here under inetd */ fprintf(stdout, "Returned from call to shmget()\n"); fflush(stdout); /* Get to here if run interactively under user acct */ ptr = (struct shseg *)shmat(segid, (char *) 0, SHM_RDONLY); if ((int)ptr == -1) { fprintf(stdout, "Segment is not defined\n"); fflush(stdout); return; /* cannot process further */ } shmdt((char *)ptr); } Configuration fragment for /etc/inetd.conf: ------------------------------------------- testseg stream tcp nowait root /home/testacct/testseg testseg Configuration fragment for /etc/services: ----------------------------------------- testseg 9190/tcp #Test interaction of shmget and inetd Results under FC3: ------------------ $ ./testseg About to call shmget() Returned from call to shmget() Segment is not defined $ telnet localhost testseg Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. About to call shmget() Returned from call to shmget() Segment is not defined Connection closed by foreign host. Results under Cygwin: --------------------- $ ./testseg.exe About to call shmget() Returned from call to shmget() Segment is not defined $ telnet localhost testseg Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. About to call shmget() Connection closed by foreign host. ------------------------------------------------------------------------ --- Has anyone else encountered this problem? Regards, John -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/