Last active
August 3, 2019 22:30
-
-
Save gatlin/ea71d3b8410c7687c0e1258b80acb3e7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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