/* This function will close the pipe and release the pipe buffer.  */
rt_err_t rt_pipe_close(rt_device_t device)
/* This function will close the pipe and release the pipe buffer.  */
rt_err_t rt_pipe_close(rt_device_t device)
{
    rt_pipe_t *pipe = (rt_pipe_t *)device;
    if (device == RT_NULL)
    {
        return -RT_EINVAL;
    }
    rt_mutex_take(&pipe->lock, RT_WAITING_FOREVER);
    rt_ringbuffer_destroy(pipe->fifo);
    pipe->fifo = RT_NULL;
    rt_mutex_release(&pipe->lock);
    return RT_EOK;
}