Skip to content

Instantly share code, notes, and snippets.

@gatlin
Last active August 3, 2019 22:30
Show Gist options
  • Save gatlin/ea71d3b8410c7687c0e1258b80acb3e7 to your computer and use it in GitHub Desktop.
Save gatlin/ea71d3b8410c7687c0e1258b80acb3e7 to your computer and use it in GitHub Desktop.
/* 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