Hi,
I caught the following thread on comp.os.qnx:
http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=ab3322aa77227c12
According to Dmitri Antipov <dmitry.antipov@auriga.ru> stated that the
following
call to mmap will fail under QNX:
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/mman.h>
int
main (int argc, char *argv[])
{
int fd;
char mem;
struct stat buf;
if ((fd = open (++argv, O_RDONLY)) < 0) {
printf (“open(”%s",…) oops (%s)\n", *argv, strerror (errno));
exit (errno);
}
if (lstat (*argv, &buf) < 0) {
printf (“lstat(”%s",…) oops (%s)\n", *argv, strerror (errno));
exit (errno);
}
if ((mem = mmap (NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0))==
MAP_FAILED){
printf (“mmap(”%s",…) oops (%s)\n", *argv, strerror (errno));
exit (errno);
}
printf (“mmap(”%s",…) ok, %d bytes at %p\n", *argv, buf.st_size,
mem);
munmap (mem, buf.st_size);
close (fd);
return 0;
}
Why is this the case, and what is the workaround?
I believe that this problem is one of the problems
causing the ACE library to crash under QNX
(refer to the thread in this newsgroup: QNX, ACE, and gcc,
started by my colleague, Prakash Manghwani).
Craig Rodrigues Distributed Systems and Logistics
crodrigu@bbn.com BBN Technologies
Cambridge, MA