diff --git a/src/lib.rs b/src/lib.rs index bb2c21d..b9de136 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -69,10 +69,13 @@ pub fn unlink_id(id: i32) -> Result<(), SysvMqError> { } } -pub fn unlink_key(key: i32) -> Result<(), SysvMqError> { +pub fn id_from_key(key: i32) -> Result { let id = unsafe { msgget(key, 0) }; - unlink_id(id) + match id { + -1 => Err(SysvMqError::ErrnoError(Errno::from_i32(errno()).desc())), + id => Ok(id), + } } pub struct SysvMq {