Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sem_destroy(3) [netbsd man page]

SEM_DESTROY(3)						   BSD Library Functions Manual 					    SEM_DESTROY(3)

NAME
sem_destroy -- destroy an unnamed semaphore LIBRARY
POSIX Real-time Library (librt, -lrt) SYNOPSIS
#include <semaphore.h> int sem_destroy(sem_t *sem); DESCRIPTION
The sem_destroy() function destroys the unnamed semaphore pointed to by sem. After a successful call to sem_destroy(), sem is unusable until re-initialized by another call to sem_init(). RETURN VALUES
The sem_destroy() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. ERRORS
sem_destroy() will fail if: [EBUSY] There are currently threads blocked on the semaphore that sem points to. [EINVAL] sem points to an invalid semaphore. SEE ALSO
sem_init(3) STANDARDS
sem_destroy() conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). POSIX does not define the behavior of sem_destroy() if called while there are threads blocked on sem, but this implementation is guaranteed to return -1 and set errno to EBUSY if there are threads blocked on sem. BSD
January 22, 2003 BSD

Check Out this Related Man Page

sem_destroy(3C) 					   Standard C Library Functions 					   sem_destroy(3C)

NAME
sem_destroy - destroy an unnamed semaphore SYNOPSIS
#include <semaphore.h> int sem_destroy(sem_t *sem); DESCRIPTION
The sem_destroy() function is used to destroy the unnamed semaphore indicated by sem. Only a semaphore that was created using sem_init(3C) may be destroyed using sem_destroy(); the effect of calling sem_destroy() with a named semaphore is undefined. The effect of subsequent use of the semaphore sem is undefined until sem is re-initialized by another call to sem_init(3C). It is safe to destroy an initialised semaphore upon which no threads are currently blocked. The effect of destroying a semaphore upon which other threads are currently blocked is undefined. RETURN VALUES
If successful, sem_destroy() returns 0, otherwise it returns -1 and sets errno to indicate the error. ERRORS
The sem_destroy() function will fail if: EINVAL The sem argument is not a valid semaphore. The sem_destroy() function may fail if: EBUSY There are currently processes (or LWPs or threads) blocked on the semaphore. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ |ATTRIBUTE TYPE |ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ SEE ALSO
sem_init(3C), sem_open(3C), attributes(5), standards(5) SunOS 5.11 5 Feb 2008 sem_destroy(3C)
Man Page

8 More Discussions You Might Find Interesting

1. Programming

semaphores

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)
Discussion started by: qntmteleporter
2 Replies

2. Programming

pthread_mutex_init v. sem_init v. sem_get

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)
Discussion started by: siegfried
5 Replies

3. Homework & Coursework Questions

Operating system LINUX

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)
Discussion started by: paradise
1 Replies

4. Homework & Coursework Questions

Operating system LINUX

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)
Discussion started by: paradise
0 Replies

5. UNIX for Dummies Questions & Answers

semaphore removal

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)
Discussion started by: joker40
1 Replies

6. AIX

Cannot create user using SMITTY

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)
Discussion started by: thecobra151
13 Replies

7. Programming

bounded buffer implementation

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)
Discussion started by: amejoish
15 Replies

8. Programming

Losing signal problem

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)
Discussion started by: DendyGamer
5 Replies