Exemple #1
0
// GetSharedMem creates or retrieves the shared memory segment for an IPC key
func GetSharedMem(key int64, size uint64, flags *SHMFlags) (*SharedMem, error) {
	rc, err := C.shmget(C.key_t(key), C.size_t(size), C.int(flags.flags()))
	if rc == -1 {
		return nil, err
	}
	return &SharedMem{int64(rc), uint(size)}, nil
}
Exemple #2
0
// GetMsgQueue creates or retrieves a message queue id for a given IPC key.
func GetMsgQueue(key int64, flags *MQFlags) (MessageQueue, error) {
	rc, err := C.msgget(C.key_t(key), C.int(flags.flags()))
	if rc == -1 {
		return -1, err
	}
	return MessageQueue(rc), nil
}
Exemple #3
0
// GetSemSet creates or retrieves the semaphore set for a given IPC key.
func GetSemSet(key, count int64, flags *SemSetFlags) (*SemaphoreSet, error) {
	rc, err := C.semget(C.key_t(key), C.int(count), C.int(flags.flags()))
	if rc == -1 {
		return nil, err
	}
	return &SemaphoreSet{int64(rc), uint(count)}, nil
}
Exemple #4
0
// msgget(2)
// int msgget(key_t key, int msgflg);
func msgget(key int, mode int) (int, error) {
	res, err := C.msgget(C.key_t(key), C.int(mode))

	if err != nil {
		return -1, err
	}

	return int(res), nil
}