GIOChannel にて scanf でよく使う行末から値を得るように。
#include <glib.h>
int
main (int argc, char* argv[]) {
GError *error = NULL;
GIOChannel *channel;
gchar *text;
gsize length, terminator_pos;
g_printf("Input :");
channel = g_io_channel_unix_new(0);
g_io_channel_read_line(channel, &text, &length, &terminator_pos, &error);
g_io_channel_unref(channel);
text[terminator_pos] = '\0';
g_printf("output[%s]\n", text);
g_free(text);
return 0;
}

なんだよコレ、いきなり入力画面になるんだが。
しばらく悩んでやっと手段を見つける。
#include <glib.h>
int
main (int argc, char* argv[]) {
GError *error = NULL;
GIOChannel *channel;
gchar *text;
gsize length, terminator_pos;
g_printf("Input\n"); /* Important '\n' */
channel = g_io_channel_unix_new(0);
g_io_channel_read_line(channel, &text, &length, &terminator_pos, &error);
g_io_channel_unref(channel);
text[terminator_pos] = '\0';
g_printf("output[%s]\n", text);
g_free(text);
return 0;
}

改行するだけだった、いやだから行末から値を得たいのですけど。
GIOChannel では一行単位でしか値を得られないのだろうか。
よくワカラン、ならば入力も GIOChannel にしたらどうだ?
これは上手くいったのでコメントと例外処理を付ける(外国人用)
#include <glib.h>
int
main (int argc, char* argv[]) {
GError *error = NULL;
GIOChannel *channel;
GIOStatus status;
gchar *text;
gsize length, terminator_pos;
for (;;) {
/* stdout */
channel = g_io_channel_unix_new(1);
status = g_io_channel_write_chars(channel, "Exit if string is empty :", -1, NULL, &error);
if (status == G_IO_STATUS_ERROR) {
g_warning (error->message);
g_error_free (error);
g_io_channel_unref(channel);
return 1;
}
g_io_channel_unref(channel);
/* stdin */
channel = g_io_channel_unix_new(0);
/* Start from the end of the line */
status = g_io_channel_read_line(channel, &text, &length, &terminator_pos, &error);
if (status == G_IO_STATUS_ERROR) {
g_warning (error->message);
g_error_free (error);
g_io_channel_unref(channel);
return 2;
}
g_io_channel_unref(channel);
/* Exit if string is empty */
if (terminator_pos == 0) {
g_free(text);
break;
}
/* Remove '\n' */
text[terminator_pos] = '\0';
g_printf("[%s]\n", text);
g_free(text);
}
return 0;
}

g_io_channel_write_chars での出力なら当然のごとく行末からに。
g_printf がバッファの行末へ入出力ポインタを seek しないのかな。
いや、g_printf を連続して呼べば追記になるのだからそれは違う。
単純にまったく別のポインタ管理をしているのかも。
もしそうなら下記のようにすれば上書きか挿入かがされるはず。
#include <glib.h>
int
main (int argc, char* argv[]) {
GIOChannel *channel;
g_printf("First");
g_printf("Second");
channel = g_io_channel_unix_new(1);
g_io_channel_write_chars(channel, "Third", -1, NULL, NULL);
g_io_channel_unref(channel);
return 0;
}

見事に挿入されてしまった、そういうことか。
最初のいきなり入力画面は表示できない二行目に押し出されていたのね。
日本語情報が無いに等しいから自分で見つけるしかないのが辛いNE。
GIOChannel と g_printf は混在させないのが無難、という結論で。