Boost logo

Boost :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-11-14 14:43:01


Ion Gaztanaga wrote:
> I wasn't expecting permission problems, though ;-) Could you tell me a
> shared memory name that a user could use successfully in HP-UX?

It is not just HP-UX. You would've had the same problem on Tru64 or VMS
if the codepath that is taken on HP-UX was executed on these platforms --
see below.

[ As a side remark: your check for whether the platform supports shared
 memory objects assumes that this functionality is available only if the
 macro _POSIX_SHARED_MEMORY_OBJECTS is defined with a value greater than
 zero. While this is correct assumption for X/Open Issue 6: The Open Group
 Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition, it is not a
 correct assumption for X/Open Issue 5: The Single UNIX Specification,
 Version 2, also known as UNIX 98. In UNIX 98, the macro can be defined
 with any value -- see
 <http://www.opengroup.org/onlinepubs/007908799/xsh/unistd.h.html>

 As I said in the previous mail, Tru64 defines _POSIX_SHARED_MEMORY_OBJECTS
 as an empty string and your check for shared memory objects availability
 fails on this platform, which is good in a sense :-) ]

To answer your question, I think, that prepending
"/tmp/boost_interprocess/" to the name is a good solution. You already do
it on platforms which fail your shared memory objects availability check.

Thanks,
  Boris

HP-UX
-----
bash-2.03$ cc -V
cc: HP C/aC++ B3910B A.06.14 [Feb 22 2007]
bash-2.03$ cc x.c && a.out
shm_open: Permission denied
bash-2.03$

Tru64
-----
cxxosf.zko.hp.com> cc -V
Compaq C V6.5-207 (dtk) on Compaq Tru64 UNIX V5.1B (Rev. 2650)
Compiler Driver V6.5-207 (dtk) (dtk) cc Driver
cxxosf.zko.hp.com> cc x.c -lrt && a.out
shm_open: Permission denied
cxxosf.zko.hp.com>

VMS

---
ICXXC::_1> cc/ver
HP C V7.3-018 on OpenVMS IA64 XBPK-O3N
ICXXC::_1> define DECC$POSIX_COMPLIANT_PATHNAMES 1
ICXXC::_1> pipe cc x.c ; link x.obj ; run x.exe
shm_open: permission denied
ICXXC::_1>
x.c
---
#include <sys/mman.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/stat.h>
int main() {
  int fd;
  char *name = "/shm_name";
  int oflag = O_RDWR | O_CREAT | O_EXCL;
  fd = shm_open(name, oflag, S_IRWXO | S_IRWXG | S_IRWXU);
  if ( fd == -1 )
    perror("shm_open");
  else {
    puts("success");
    shm_unlink(name);
  }
}

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk