SEM_DESTROY(3) Linux Programmer's Manual SEM_DESTROY(3)NAME
sem_destroy - destroy an unnamed semaphore
SYNOPSIS
#include <semaphore.h>
int sem_destroy(sem_t *sem);
Link with -lrt or -pthread.
DESCRIPTION
sem_destroy() destroys the unnamed semaphore at the address pointed to by sem.
Only a semaphore that has been initialized by sem_init(3) should be destroyed using sem_destroy().
Destroying a semaphore that other processes or threads are currently blocked on (in sem_wait(3)) produces undefined behavior.
Using a semaphore that has been destroyed produces undefined results, until the semaphore has been reinitialized using sem_init(3).
RETURN VALUE
sem_destroy() returns 0 on success; on error, -1 is returned, and errno is set to indicate the error.
ERRORS
EINVAL sem is not a valid semaphore.
CONFORMING TO
POSIX.1-2001.
NOTES
An unnamed semaphore should be destroyed with sem_destroy() before the memory in which it is located is deallocated. Failure to do this
can result in resource leaks on some implementations.
SEE ALSO sem_init(3), sem_post(3), sem_wait(3), sem_overview(7)COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2006-03-25 SEM_DESTROY(3)
Check Out this Related Man Page
SEM_DESTROY(3) Linux Programmer's Manual SEM_DESTROY(3)NAME
sem_destroy - destroy an unnamed semaphore
SYNOPSIS
#include <semaphore.h>
int sem_destroy(sem_t *sem);
Link with -lrt or -pthread.
DESCRIPTION
sem_destroy() destroys the unnamed semaphore at the address pointed to by sem.
Only a semaphore that has been initialized by sem_init(3) should be destroyed using sem_destroy().
Destroying a semaphore that other processes or threads are currently blocked on (in sem_wait(3)) produces undefined behavior.
Using a semaphore that has been destroyed produces undefined results, until the semaphore has been reinitialized using sem_init(3).
RETURN VALUE
sem_destroy() returns 0 on success; on error, -1 is returned, and errno is set to indicate the error.
ERRORS
EINVAL sem is not a valid semaphore.
CONFORMING TO
POSIX.1-2001.
NOTES
An unnamed semaphore should be destroyed with sem_destroy() before the memory in which it is located is deallocated. Failure to do this
can result in resource leaks on some implementations.
SEE ALSO sem_init(3), sem_post(3), sem_wait(3), sem_overview(7)COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2006-03-25 SEM_DESTROY(3)
Hi there,
Could someone please confirm which POSIX semaphore routines should be used for a multiprocess (and not multithreaded) environment?
sys/sem.h definitely works. but the routines, semget, semctl, semop are pretty unwieldy. So, I am looking for an easier way out.
From the man pages... (2 Replies)
Apparently there are three similar features in the linux API. Can someone explain the difference between the data structures that are initialized by these functions:
(1) pthread_mutex_init
(2) sem_init
(3) sem_get
Thanks,
Siegfried (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be
produced.... (1 Reply)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Write a C program that accepts 3 parameters. Each parameter indicates the quantity of product to be
produced.... (0 Replies)
I have one process which creates semaphore with permission 600. Then at some part of the code I have line where this semaphore will be removed. Problem I have is that other processes in my program also try to execute this line of code. Of course since they dont have permission they wont be able to... (1 Reply)
i'm using smitty to create user...what happen is it prompt me "failed" with error
3004-703 Check "/etc/security/login.cfg" file.
3004-691 Error changing "shell".
3004-703 Check "/usr/lib/security/mkuser.default" file.
3004-721 Could not create user.
3004-703 Check... (13 Replies)
Hi Experts,
I have a programming assignment that asks us to implement a pipegrep function. it basically has 5 stages and each stage has a thread and buffers are used between stages.
am currently implementing stage 1 . In stage 1 am suppose to read directory and store the filenames in buffer1... (15 Replies)
I'm newbie in UNIX programming, I have a problem with signals. I'm writing multithread program, where threads can die at any moment. When thread dies it generates signal SIGUSR1 to main thread and then thread dies. Main thread gets a signal and waits for thread dead.
I wrote program like this:
... (5 Replies)