#fd #unix #socket #domain


A library to support fd passing on Unix sockets

9 releases (2 stable)

1.1.0 Aug 21, 2022
1.0.0 Jul 18, 2022
1.0.0-beta.3 Dec 28, 2020
1.0.0-beta.2 Sep 26, 2020

#172 in Unix APIs

Download history 3/week @ 2023-06-07 17/week @ 2023-06-14 39/week @ 2023-06-21 14/week @ 2023-06-28 28/week @ 2023-07-05 10/week @ 2023-07-12 19/week @ 2023-07-19 13/week @ 2023-07-26 7/week @ 2023-08-02 11/week @ 2023-08-09 18/week @ 2023-08-16 10/week @ 2023-08-23 16/week @ 2023-08-30 27/week @ 2023-09-06 10/week @ 2023-09-13 7/week @ 2023-09-20

63 downloads per month
Used in 3 crates (2 directly)


1.5K SLoC

FD Queue

FD Queue is a Rust abstraction for passing file descriptors between processes.

CI doc Crates.io Release

fd-queue provides traits for enqueuing and dequeuing file descriptors and implementations of those traits for different types of Unix sockets. Specifically fd-queue provides a blocking implementation, a non-blocking implementation base on mio, and a non-blocking implementation based on tokio.


Add this to your Cargo.toml

fd-queue = {version = "1.0.0", features = ["net-fd"]}

This enables the blocking implementation of the traits for enqueuing and dequeuing file descriptors. See below for the other features. You can then use the library as follows:

use std::{
use fd_queue::{EnqueueFd, DequeueFd, UnixStream};

let (mut sock1, mut sock2) = UnixStream::pair()?;

// sender side
let file: File = ...
sock1.enqueue(&file).expect("Can't enquque the file descriptor.");

//receiver side
let mut buf = [0u8; 1];
sock2.read(&mut buf)?;
let fd = sock2.dequeue().expect("Can't dequeue the file descriptor.");
let file2 = unsafe { File::from_raw_fd(fd) };


Usage of the library with the default features will include only the basic trait definitions DequeueFd and EnqueueFd together with their supporting types. With the default features there will be no implementations of the basic traits. To include implementations of the traits enable the following features:

Feature Implementation Additional Traits
net-fd blocking Read, Write
mio-fd non-blocking Read, Write, Evented
tokio-fd non-blocking AsyncRead, AsyncWrite

Rust Version Requirements

The library will always support the Rust version that is two earlier than the current stable version. The current Minimum Supported Rust Version (MSRV) is 1.61.0. Any change to the MSRV will be treated as a minor change for Semantic Version purposes.

Semantic Version and Release

This library follows semantic versioning.

The first non-pre-release version of the library will be version 1.0.0. This does not signal that the library is production ready or that we will attempt to avoid breaking changes. It rather signals exactly what the Semantic Versioning Specification says it does: there won't be any backward incompatible changes until version 2.0.0 (see here).

For a signal of the maturity of the library see the next heading which will be updated as the library matures.


This library is an initial, experimental implementation that has not had any use in production. You should expect breaking changes (with an appropriate change in semantic version) as the library matures.


FD Queue is licensed under either of

at your option.


Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in FD Queue by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~90K SLoC