By running the above program, I am getting the following output Can't create semaphore Can't open semaphore

The output shows that its failed to create a semaphore and even failed to open semaphore. creating a semaphore might have failed if a semaphore already exists with the given name. I don't understand why opening a semaphore failed.

Can some clarify the scenario where both creating semaphore & opening semaphore fails.

Are there any permissions with semaphore such that a new semaphore created can be accessed only by certain processes??