1 /* SPDX-License-Identifier: MIT-0 */
6 #include <systemd/sd-bus.h>
8 int writer_with_negative_errno_return(int fd
, sd_bus_error
*error
) {
9 const char *message
= "Hello, World!\n";
11 ssize_t n
= write(fd
, message
, strlen(message
));
13 return n
; /* On success, return the number of bytes written, possibly 0. */
15 /* On error, initialize the error structure, and also propagate the errno
16 * value that write(2) set for us. */
17 return sd_bus_error_set_errnof(error
, errno
, "Failed to write to fd %i: %m", fd
);