X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=util.c;h=eed9aa7f84e598a5d92ed8fac733fd030ec3b695;hb=41160f3dbf0cb61e23a02338da1f289a2ff00066;hp=9d99fefe78b8ce5e373e52e91084988d8c938893;hpb=b1b2dc0ce9fb04d1c1a6ed0a4fee7011a79602f6;p=elogind.git diff --git a/util.c b/util.c index 9d99fefe7..eed9aa7f8 100644 --- a/util.c +++ b/util.c @@ -1199,6 +1199,7 @@ bool ignore_file(const char *filename) { return filename[0] == '.' || + streq(filename, "lost+found") || endswith(filename, "~") || endswith(filename, ".rpmnew") || endswith(filename, ".rpmsave") || @@ -1677,13 +1678,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; }