Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

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

807575Feb 20 2007 — edited Feb 21 2007
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2007
Added on Feb 20 2007
2 comments
142 views