// Set updates parameters of the semaphore set. func (ss *SemaphoreSet) Set(ssi *SemSetInfo) error { sds := &C.struct_semid_ds{ sem_perm: C.struct_ipc_perm{ uid: C.__uid_t(ssi.Perms.OwnerUID), gid: C.__gid_t(ssi.Perms.OwnerGID), mode: C.ushort(ssi.Perms.Mode & 0x1FF), }, } rc, err := C.semctl_buf(C.int(ss.id), C.IPC_SET, sds) if rc == -1 { return err } return nil }
// Stat produces information about the semaphore set. func (ss *SemaphoreSet) Stat() (*SemSetInfo, error) { sds := C.struct_semid_ds{} rc, err := C.semctl_buf(C.int(ss.id), C.IPC_STAT, &sds) if rc == -1 { return nil, err } ssinf := SemSetInfo{ Perms: IpcPerms{ OwnerUID: int(sds.sem_perm.uid), OwnerGID: int(sds.sem_perm.gid), CreatorUID: int(sds.sem_perm.cuid), CreatorGID: int(sds.sem_perm.cgid), Mode: uint16(sds.sem_perm.mode), }, LastOp: time.Unix(int64(sds.sem_otime), 0), LastChange: time.Unix(int64(sds.sem_ctime), 0), Count: uint(sds.sem_nsems), } return &ssinf, nil }