Skip to content

Instantly share code, notes, and snippets.

@gatlin gatlin/write_to_fd.c
Last active Aug 3, 2019

Embed
What would you like to do?
/* Helper function which writes a string to a file descriptor.
*/
static gboolean
write_to_fd (int fd, const gchar *message) {
gsize bw;
GIOChannel *channel = g_io_channel_unix_new (fd);
GString *message_str = g_string_new (message);
g_string_append (message_str, "\n");
g_io_channel_write_chars (channel,
message_str->str,
message_str->len,
&bw,
NULL);
g_string_free (message_str, TRUE);
g_io_channel_shutdown (channel, TRUE, NULL);
g_io_channel_unref (channel);
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.