unlock()

Release a PSL process lock.

Syntax

unlock(lockname)

Parameter

ParameterDefinition

lockname

name of the lock that should be released

Description

The unlock() function releases lockname that was granted to this process by a previous call to the lock() function. The unlock() function returns 1 for success and 0 for failure. If no lock is named lockname or if it is not currently owned by this process, then the unlock() function reports a run-time error, sets the PSL errno variable, and returns 0.

Note

All locks held by a process are automatically released when the process exits in a manner similar to executing the unlock function. BMC Software recommends that you release locks explicitly using the unlock() function rather than implicitly using the process exit.

If this process is the only one holding the lock and processes are queued for it, the first waiting process is awakened and granted use of the lock. If the first process is a shared request, then any other processes that are queued for a shared lock are also granted shared access to the lock (except for processes that are behind a writer request on the queue for this lock).

Example

The following is an example of the unlock() function:

if (unlock(PASSWD_LOCK)) {
printf("lock released\n”);
} else {
printf("lock release failed\n”);
}


Was this page helpful? Yes No Submitting... Thank you

Comments