test: Fix tty-test program

The "tty ready" string must only be printed when the process is ready to receive
signals, and this only happens when the event loop has started.
This commit is contained in:
Thiago de Arruda 2015-03-24 07:45:36 -03:00
parent 56ef37eb59
commit d6369707c2

View File

@ -80,6 +80,12 @@ static void read_cb(uv_stream_t *stream, ssize_t cnt, const uv_buf_t *buf)
free(buf->base);
}
static void prepare_cb(uv_prepare_t *handle)
{
fprintf(stderr, "tty ready\n");
uv_prepare_stop(handle);
}
int main(int argc, char **argv)
{
if (!is_terminal(stdin)) {
@ -98,7 +104,9 @@ int main(int argc, char **argv)
}
bool interrupted = false;
fprintf(stderr, "tty ready\n");
uv_prepare_t prepare;
uv_prepare_init(uv_default_loop(), &prepare);
uv_prepare_start(&prepare, prepare_cb);
uv_tty_t tty;
uv_tty_init(uv_default_loop(), &tty, fileno(stderr), 1);
uv_read_start((uv_stream_t *)&tty, alloc_cb, read_cb);