SD\_IS\_FIFO(3) sd\_is\_fifo SD\_IS\_FIFO(3)

.SH "NAME" sd\_is\_fifo, sd\_is\_socket, sd\_is\_socket\_inet, sd\_is\_socket\_unix, sd\_is\_socket\_sockaddr, sd\_is\_mq, sd\_is\_special - Check the type of a file descriptor

.SH "SYNOPSIS"

```
#include <systemd/sd-daemon.h>
```

.HP 360u **int sd\_is\_fifo(int fd, const char \*path);**

.HP 408u **int sd\_is\_socket(int fd, int family, int type, int listening);**

.HP 528u **int sd\_is\_socket\_inet(int fd, int family, int type, int listening, uint16\_t port);**

.HP 624u **int sd\_is\_socket\_sockaddr(int fd, int type, const struct sockaddr \*addr, unsigned addr\_len, int listening);**

.HP 528u **int sd\_is\_socket\_unix(int fd, int type, int listening, const char \*path, size\_t length);**

.HP 312u **int sd\_is\_mq(int fd, const char \*path);**

.HP 432u **int sd\_is\_special(int fd, const char \*path);**

.SH "DESCRIPTION"

.PP **sd\_is\_fifo()** may be called to check whether the specified file descriptor refers to a FIFO or pipe. If the *path* parameter is not **NULL**, it is checked whether the FIFO is bound to the specified file system path.

.PP **sd\_is\_socket()** may be called to check whether the specified file descriptor refers to a socket. If the *family* parameter is not **AF\_UNSPEC**, it is checked whether the socket is of the specified family (**AF\_UNIX**, **AF\_INET**, ...). If the *type* parameter is not 0, it is checked whether the socket is of the specified type (**SOCK\_STREAM**, **SOCK\_DGRAM**, ...). If the *listening* parameter is positive, it is checked whether the socket is in accepting mode, i.e. **listen()** has been called for it. If *listening* is 0, it is checked whether the socket is not in this mode. If the parameter is negative, no such check is made. The *listening* parameter should only be used for stream sockets and should be set to a negative value otherwise.

.PP **sd\_is\_socket\_inet()** is similar to **sd\_is\_socket()**, but optionally checks the IPv4 or IPv6 port number the socket is bound to, unless *port* is zero. For this call *family* must be passed as either **AF\_UNSPEC**, **AF\_INET**, or **AF\_INET6**.

.PP **sd\_is\_socket\_sockaddr()** is similar to **sd\_is\_socket\_inet()**, but checks if the socket is bound to the address specified by *addr*. The *family* specified by *addr* must be either **AF\_INET** or **AF\_INET6** and *addr\_len* must be large enough for that family. If *addr* specifies a non-zero port, it is also checked if the socket is bound to this port. In addition, for IPv6, if *addr* specifies non-zero *sin6\_flowinfo* or *sin6\_scope\_id*, it is checked if the socket has the same values.

.PP **sd\_is\_socket\_unix()** is similar to **sd\_is\_socket()** but optionally checks the **AF\_UNIX** path the socket is bound to, unless the *path* parameter is **NULL**. For normal file system **AF\_UNIX** sockets, set the *length* parameter to 0. For Linux abstract namespace sockets, set the *length* to the size of the address, including the initial 0 byte, and set the *path* to the initial 0 byte of the socket address.

.PP **sd\_is\_mq()** may be called to check whether the specified file descriptor refers to a POSIX message queue. If the *path* parameter is not **NULL**, it is checked whether the message queue is bound to the specified name.

.PP **sd\_is\_special()** may be called to check whether the specified file descriptor refers to a special file. If the *path* parameter is not **NULL**, it is checked whether the file descriptor is bound to the specified filename. Special files in this context are character device nodes and files in /proc/ or /sys/.

.SH "RETURN VALUE"

.PP On failure, these calls return a negative errno-style error code. If the file descriptor is of the specified type and bound to the specified address, a positive return value is returned, otherwise zero.

.SH "NOTES"

.PP Functions described here are available as a shared library, which can be compiled against and linked to with the **libsystemd** [**pkg-config**(1)](/man/os/systemd/pkg-config.1) file.

.PP Internally, these functions use a combination of [**fstat**(2)](/man/os/systemd/fstat.2) and [**getsockname**(2)](/man/os/systemd/getsockname.2) to check the file descriptor type and where it is bound to.

.SH "HISTORY"

.PP **sd\_is\_special()** was added in version 209.

.PP **sd\_is\_socket\_sockaddr()** was added in version 233.

.SH "SEE ALSO"

.PP [**systemd**(1)](/man/os/systemd/systemd.1), [**sd-daemon**(3)](/man/os/systemd/sd-daemon.3), [**sd\_listen\_fds**(3)](/man/os/systemd/sd_listen_fds.3), [**systemd.service**(5)](/man/os/systemd/systemd.service.5), [**systemd.socket**(5)](/man/os/systemd/systemd.socket.5), [**ip**(7)](/man/os/systemd/ip.7), [**ipv6**(7)](/man/os/systemd/ipv6.7), [**unix**(7)](/man/os/systemd/unix.7), [**fifo**(7)](/man/os/systemd/fifo.7), [**mq\_overview**(7)](/man/os/systemd/mq_overview.7), [**socket**(7)](/man/os/systemd/socket.7).

systemd 262.2

---

Document: sd_is_fifo(3) from systemd 262.2-r1 (Chainguard OS)
Source: https://github.com/systemd/systemd
