tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Strange semaphore behavior, sem_init() fails with errno 4294967295 (-1)



I have forgotten a precision.

In each thread, my software does a fork() followed by an execve(). If I
remove this fork(), I'm unable to reproduce this bug. Maybe sem_init()
returns an error when fork() is called form another thread.

That's beeing said, sem_init in librt is :

int
sem_init(sem_t *sem, int pshared, unsigned int value)
{
    intptr_t    semid;
    int error;

    if (_ksem_init(value, &semid) == -1)
        return (-1);

    if ((error = sem_alloc(value, semid, sem)) != 0) {
        _ksem_destroy(semid);
        errno = error;
        return (-1);
    }

    return (0);
}

As errno contains an error, I suppose that sem_alloc() returns this
error, but sem_alloc() can only return ENOSPC or EINVAL...

	Best regards,

	JKB


Home | Main Index | Thread Index | Old Index