Mail Archives: cygwin/2003/02/04/11:56:08
--Boundary_(ID_NJqKOa+kA/ajTszTBLE0xg)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT
Content-disposition: inline
Corinna,
While attempting to get PostgreSQL's PL/Tcl to work under Cygwin, I
stumbled onto another mmap() issue. The two attachments, server.c and
open2.c, are a minimal test case that demonstrates the problem:
$ date > /tmp/cygipc_0
$ server /tmp/cygipc_0&
[1] 2456
$ strace open2 /tmp/cygipc_0 | fgrep 'unknown windows error'
197 51623 [main] open2 2948 geterrno_from_win_error: unknown windows error 1224, setting errno to 13
$ fgrep 1224 /usr/include/w32api/winerror.h
#define ERROR_USER_MAPPED_FILE 1224L
The root cause of the problem is opening the file with the "O_TRUNC"
flag -- without it, the open (in open2) succeeds. Unfortunately, cygipc
seems to need open with truncation semantics for proper operation.
Is there any way to work around this problem? Or, is this just an
inherent Windows limitation? I'm afraid the latter will be the case.
So far Cygwin PostgreSQL users have been fortunate, since only PL/Tcl
seems to trigger the sequence of IPC (i.e., cygipc) operations that
causes this failure.
Thanks,
Jason
--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D 8784 1AFD E4CC ECF4 8EF6
--Boundary_(ID_NJqKOa+kA/ajTszTBLE0xg)
Content-type: text/plain; charset=us-ascii; NAME=server.c
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=server.c
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
int
main(int argc, char* argv[])
{
int fd = -1;
off_t len = 0, status = 0;
const char* file = argv[1];
void* p = 0;
fd = open (file, O_RDWR, 00666);
if (fd == -1)
{
printf("open(): fd = %d, errno %d\n", fd, errno);
exit(1);
}
len = lseek(fd, 0, SEEK_END);
if (len == -1)
{
printf("lseek(SEEK_END): errno %d\n", errno);
exit(1);
}
status = lseek(fd, 0, SEEK_SET);
if (len == -1)
{
printf("lseek(SEEK_SET): errno %d\n", errno);
exit(1);
}
p = mmap (0, len, (PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
if (p == MAP_FAILED)
{
printf("mmap(): errno %d\n", errno);
exit(1);
}
sleep(300);
return 0;
}
--Boundary_(ID_NJqKOa+kA/ajTszTBLE0xg)
Content-type: text/plain; charset=us-ascii; NAME=open2.c
Content-transfer-encoding: 7BIT
Content-disposition: attachment; filename=open2.c
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
int
main(int argc, char* argv[])
{
const char* filename = argv[1];
int fd;
fd = open (filename, O_CREAT|O_RDWR|O_TRUNC, 00666);
printf("fd = %d errno %d\n", fd, errno);
return 0;
}
--Boundary_(ID_NJqKOa+kA/ajTszTBLE0xg)
Content-Type: text/plain; charset=us-ascii
--
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/
--Boundary_(ID_NJqKOa+kA/ajTszTBLE0xg)--
- Raw text -