1SD_BUS_SET_FD(3) sd_bus_set_fd SD_BUS_SET_FD(3)
2
3
4
6 sd_bus_set_fd - Set the file descriptors to use for bus communication
7
9 #include <systemd/sd-bus.h>
10
11 int sd_bus_set_fd(sd_bus *bus, int input_fd, int output_fd);
12
14 sd_bus_set_fd() sets the file descriptors used to communicate by a bus
15 connection object. Both input_fd and output_fd must be valid file
16 descriptors, referring to stream-based file objects (e.g. a stream
17 socket, a pair of pipes or FIFOs, or even a TTY device). input_fd must
18 be readable, and output_fd must be writable. The same file descriptor
19 may be used (and typically is used) as both the input and the output
20 file descriptor. This function must be called before the bus connection
21 is started via sd_bus_start(3).
22
23 The bus connection object will take possession of the passed file
24 descriptors and will close them automatically when it is freed. Use
25 sd_bus_set_close_on_exit(3) to turn off this behaviour.
26
28 On success, sd_bus_set_fd() returns a non-negative integer. On failure,
29 it returns a negative errno-style error code.
30
31 Errors
32 Returned errors may indicate the following problems:
33
34 -EINVAL
35 An invalid bus object was passed.
36
37 -ECHILD
38 The bus connection was allocated in a parent process and is being
39 reused in a child process after fork().
40
41 -EBADF
42 An invalid file descriptor was passed to sd_bus_set_fd().
43
44 -ENOPKG
45 The bus cannot be resolved.
46
47 -EPERM
48 The bus connection has already been started.
49
51 Functions described here are available as a shared library, which can
52 be compiled against and linked to with the libsystemd pkg-config(1)
53 file.
54
55 The code described here uses getenv(3), which is declared to be not
56 multi-thread-safe. This means that the code calling the functions
57 described here must not call setenv(3) from a parallel thread. It is
58 recommended to only do calls to setenv() from an early phase of the
59 program when no other threads have been started.
60
62 systemd(1), sd-bus(3), sd_bus_get_fd(3), sd_bus_start(3)
63
64
65
66systemd 254 SD_BUS_SET_FD(3)