[Info-vax] Problem with sem_open() call

Alexander Saprykin xelfium at gmail.com
Wed Sep 21 06:04:16 EDT 2016


понедельник, 19 сентября 2016 г., 18:12:54 UTC+3 пользователь Stephen Hoffman написал:
> On 2016-09-19 13:19:06 +0000, Alexander Saprykin said:
> 
> > I'm trying to use POSIX semaphores introduced in OpenVMS 8.4, but with no luck.
> > 
> > 1. Calling sem_open("/myname", O_CREAT | O_EXCL, 0660, 1) returns a 
> > pointer to a semaphore structure (sem_t), no problems here.
> > 2. Calling the same routine returns EEXIST on the second time, as 
> > described in manual (so, the semaphore already exists), no problems 
> > here.
> > 3. But subsequent sem_open("/myname", 0) call fails with ENOENT error 
> > code which means that there is no semaphore with such a name. But 
> > semaphore actually exists, because even sem_unlink ("/myname") returns 
> > 0.
> > 
> > So I couldn't open semaphore after its creation.
> > 
> > Has some faced with such a problem? Maybe I need to make some system 
> > configuration changes?
> 
> Please check that your OpenVMS patches are current, as a starting 
> point.    Then please post a (small!) reproducer of the problem, and 
> post up the local definitions of the DECC* logical name morass, and 
> some folks here can use that to determine if it's OpenVMS, the local 
> system configuration, the source code involved.   Or you can ring up 
> HPE support and ask them, if you have access to that path.
> 
> 
> 
> 
> -- 
> Pure Personal Opinion | HoffmanLabs LLC

Sorry for a delay, I have been preparing a clean OpenVMS install. I'm using FreeAXP emulator with a Hobbyist PAK. So the system is OpenVMS 8.4 from the HP's FTP, CC 7.3. I'm a novice with OpenVMS and I do not have a reach experience with it. I'm trying to port my personal project (system library). If you need any information (sorry, I do not understand what do you need with "local definitions of the DECC* logical name morass"), please write down a command I need to execute to post output here.

I have prepared several small programs to reproduce the behaviour.

The first program (I call it sem_create) creates a named (system-wide, global) semaphore:

#include <semaphore.h>
#include <stdio.h>
#include <errno.h>

int main ()
{
    sem_t * my_semaphore;

    my_semaphore = sem_open ("/mysemaphore", O_CREAT | O_EXCL, 0660, 0);

    if (my_semaphore == SEM_FAILED) {
        if (errno == EEXIST)
            printf ("[OK] Semaphore exists\n");
        else
            printf ("[FAIL] Error code: %d\n", errno);
    } else
        printf ("[OK] Semaphore created\n");

    return 0;
}

The second program (I call it sem_open) tries to open an existing named semaphore:

#include <semaphore.h>
#include <stdio.h>
#include <errno.h>

int main ()
{
    sem_t * my_semaphore;

    my_semaphore = sem_open ("/mysemaphore", 0);

    if (my_semaphore == SEM_FAILED)
        printf ("[FAIL] Error code: %d\n", errno);
    else
        printf ("[OK] Semaphore opened\n");

    return 0;
}

The third program (I call it sem_unlink) removes the semaphore from the system:

#include <semaphore.h>
#include <stdio.h>
#include <errno.h>

int main ()
{
    int rc;

    rc = sem_unlink ("/mysemaphore");

    if (rc != 0)
        printf ("[FAIL] Error code: %d\n", errno);
    else
        printf ("[OK] Semaphore unlinked\n");

    return 0;
}

To reproduce the problem:

1. Launch the sem_create program to create a semaphore.
2. Launch the sem_create program again to make sure that the semaphore actually exists now.
3. Launch the sem_open program to open the semaphore created before. Instead of success, you should receive a fail here. Which is a problem I faced: the semaphore exists, but I'm not able to open it.
4. To remove the semaphore launch the sem_unlink program. Note that it removes it successfully.

I'm stuck at this for now. As for possible updates and patches: I have ALPHA084LP1.ISO and ALPHA084LP2.ISO updates from VMS Software, also I have openvms_alpha_8_4_Update500.zip and OpenVMSAlphaV84-TCP57ECO5.zip patches, but I don't know if anything of this could help me. I do not have access for HP support :( I was also trying to reach someone from VMS Software via a contact email on their web-site, but no response.

I would greatly appreciate if someone with the latest (patched) VMS can confirm (or not) the problem described above.

Best Regards,
Alexander Saprykin



More information about the Info-vax mailing list