Mail Archives: cygwin/2005/07/02/09:53:20
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 <stdio.h>
#include <cygipc/sys/ipc.h> /* use <sys/ipc.h> for FC3 */
#include <cygipc/sys/shm.h> /* use <sys/shm.h> 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/
- Raw text -