X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=util.c;h=8556ea12cd153d6899f3b98a8cc803e80b61f401;hp=fd991cf807253b88d4cc90e509dee2725bc7a96c;hb=09cd1ab12e81d486f4073bd0de14d46550834018;hpb=d4d0d4db9345170cc61a6b46ac9e11c5b8424b19 diff --git a/util.c b/util.c index fd991cf80..8556ea12c 100644 --- a/util.c +++ b/util.c @@ -1429,10 +1429,14 @@ int ask(char *ret, const char *replies, const char *text, ...) { int r; bool need_nl = true; + fputs("\x1B[1m", stdout); + va_start(ap, text); vprintf(text, ap); va_end(ap); + fputs("\x1B[0m", stdout); + fflush(stdout); if ((r = read_one_char(stdin, &c, &need_nl)) < 0) { @@ -1673,13 +1677,24 @@ fail: int release_terminal(void) { int r = 0, fd; + struct sigaction sa_old, sa_new; - if ((fd = open("/dev/tty", O_RDWR)) < 0) + if ((fd = open("/dev/tty", O_RDWR|O_NOCTTY|O_NDELAY)) < 0) return -errno; + /* Temporarily ignore SIGHUP, so that we don't get SIGHUP'ed + * by our own TIOCNOTTY */ + + zero(sa_new); + sa_new.sa_handler = SIG_IGN; + sa_new.sa_flags = SA_RESTART; + assert_se(sigaction(SIGHUP, &sa_new, &sa_old) == 0); + if (ioctl(fd, TIOCNOTTY) < 0) r = -errno; + assert_se(sigaction(SIGHUP, &sa_old, NULL) == 0); + close_nointr_nofail(fd); return r; }