|
|
1.1 ! root 1: .TH SEMGET 2 ! 2: .SH NAME ! 3: semget \- get set of semaphores ! 4: .SH SYNOPSIS ! 5: .B #include <sys/types.h> ! 6: .br ! 7: .B #include <sys/ipc.h> ! 8: .br ! 9: .B #include <sys/sem.h> ! 10: .PP ! 11: .nf ! 12: .BR "int semget (key, nsems, semflg) ! 13: .B key_t key; ! 14: .B int nsems, semflg; ! 15: .fi ! 16: .SH DESCRIPTION ! 17: .I Semget ! 18: returns the semaphore identifier associated with ! 19: .IR key . ! 20: .PP ! 21: A semaphore identifier and associated data structure and set containing ! 22: .I nsems ! 23: semaphores ! 24: (see ! 25: .IR intro (2)) ! 26: are created for ! 27: .I key ! 28: if one of the following are true: ! 29: .IP ! 30: .I Key ! 31: is equal to ! 32: .SM ! 33: .BR IPC_PRIVATE . ! 34: .IP ! 35: .I Key ! 36: does not already have a semaphore identifier associated with it, and ! 37: .RI ( semflg " & " ! 38: .SM ! 39: .BR IPC_CREAT\*S ) ! 40: is ``true''. ! 41: .PP ! 42: Upon creation, the data structure associated with the new semaphore ! 43: identifier is initialized as follows: ! 44: .IP ! 45: .BR Sem_perm.cuid ", " sem_perm.uid , ! 46: .BR sem_perm.cgid ", and " sem_perm.gid ! 47: are set equal to the effective user ! 48: .SM ID ! 49: and effective group ! 50: .SM ID\*S, ! 51: respectively, of the calling process. ! 52: .IP ! 53: The low-order 9 bits of ! 54: .B sem_perm.mode ! 55: are set equal to the low-order 9 bits of ! 56: .IR semflg . ! 57: .IP ! 58: .B Sem_nsems ! 59: is set equal to the value of ! 60: .IR nsems . ! 61: .IP ! 62: .B Sem_otime ! 63: is set equal to 0 and ! 64: .B sem_ctime ! 65: is set equal to the current time. ! 66: .PP ! 67: .I Semget ! 68: will fail if one or more of the following are true: ! 69: .TP 15 ! 70: \s-1[EINVAL]\s+1 ! 71: .I Nsems ! 72: is either less than or equal to zero or greater than the system-imposed limit. ! 73: .TP ! 74: \s-1[EACCES]\s+1 ! 75: A semaphore identifier exists for ! 76: .IR key , ! 77: but operation permission (see ! 78: .IR intro (2)) ! 79: as specified by the low-order 9 bits of ! 80: .I semflg ! 81: would not be granted. ! 82: .TP ! 83: \s-1[EINVAL]\s+1 ! 84: A semaphore identifier exists for ! 85: .IR key , ! 86: but the number of semaphores in the set associated with it is less than ! 87: .IR nsems " and " nsems ! 88: is not equal to zero. ! 89: .TP ! 90: \s-1[ENOENT]\s+1 ! 91: A semaphore identifier does not exist for ! 92: .I key ! 93: and ! 94: .RI ( semflg " &" ! 95: .SM ! 96: .BR IPC_CREAT\*S ) ! 97: is ``false''. ! 98: .TP ! 99: \s-1[ENOSPC]\s+1 ! 100: A semaphore identifier is to be created but ! 101: the system-imposed limit on the maximum number of ! 102: allowed semaphore identifiers system wide ! 103: would be exceeded. ! 104: .TP ! 105: \s-1[ENOSPC]\s+1 ! 106: A semaphore identifier is to be created but ! 107: the system-imposed limit on the maximum number of ! 108: allowed semaphores system wide ! 109: would be exceeded. ! 110: .TP ! 111: \s-1[EEXIST]\s+1 ! 112: A semaphore identifier exists for ! 113: .I key ! 114: but ! 115: .RI "((" semflg " & " ! 116: .SM ! 117: .RB IPC_CREAT\*S ") and (" ! 118: .IR semflg " & " ! 119: .SM ! 120: .BR IPC_EXCL\*S "))" ! 121: is ``true''. ! 122: .br ! 123: .if \n()s .bp ! 124: .SH "RETURN VALUE" ! 125: Upon successful completion, ! 126: a non-negative integer, ! 127: namely a semaphore identifier, is returned. ! 128: Otherwise, a value of \-1 is returned and ! 129: .I errno\^ ! 130: is set to indicate the error. ! 131: .SH SEE ALSO ! 132: intro(2), semctl(2), semop(2). ! 133: .\" @(#)semget.2 6.2 of 9/6/83
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.