sem_open() fails when run as different users on solaris 2.9

The following test program compiled and run on a solaris 2.8 machine runs fine when run as different users. i.e. when the second user calls sem_open() they can sucessfully connect to the semaphore created when the first user called sem_open().

When I repeat the test on a solaris 2.9 machine, the second user fails with EACCESS. i.e. permission denied, when trying to open the semaphore created by the first user.

Why?

#include <semaphore.h>

#include <string>

#include <errno.h>

int main(int argc, char* argv[])

{

std::string m_semname = "/SEMTEST";

const long m_mode = 0777;// read/write/execute for user and group (chmod 770)

int m_count = 1;

sem_t* m_semaphore;

m_semaphore = sem_open( m_semname.c_str(), O_CREAT, m_mode, m_count );

if ( SEM_FAILED == m_semaphore )

{

fprintf(stderr, "Error: %s\n", strerror(errno));

return 1;

}

sem_close(m_semaphore);

return 0;

}

Many thanks

Jason

[1043 byte] By [Mr_Jason_Smitha] at [2007-11-26 19:03:00]
# 1
Since this is a question about Solaris internals, and not about C++, you are more likely to get a helpful answer in a Solaris forum. Try one of the forums here http://forum.java.sun.com/index.jspa?tab=solarisor at http://opensolaris.org
clamage45a at 2007-7-9 20:49:39 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Thanks, have posted on the solaris 9 topic on forum.java.sun.comJason
Mr_Jason_Smitha at 2007-7-9 20:49:39 > top of Java-index,Development Tools,Solaris and Linux Development Tools...