summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorRonny Chevalier <chevalier.ronny@gmail.com>2015-04-15 16:05:41 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-04-15 16:05:41 -0400
commit38a4db66e7e166f3b92f15e1c66d6707fcbab69d (patch)
treea7b8de09a5c532d97c73598860000eddb7216a4e /src/shared/util.c
parent5ad9610b49875b6d65c56600d5b98d1afc11a4bd (diff)
Ronny Chevalier <chevalier.ronny@gmail.com>shared: add terminal-util.[ch]
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c52
1 files changed, 1 insertions, 51 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 0b04411f82..17ae61f90b 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -33,9 +33,6 @@
#include <fcntl.h>
#include <dirent.h>
#include <sys/ioctl.h>
-#include <linux/vt.h>
-#include <linux/tiocl.h>
-#include <termios.h>
#include <stdarg.h>
#include <poll.h>
#include <ctype.h>
@@ -71,6 +68,7 @@
#include "virt.h"
#include "process-util.h"
#include "random-util.h"
+#include "terminal-util.h"
/* Put this test here for a lack of better place */
assert_cc(EAGAIN == EWOULDBLOCK);
@@ -78,9 +76,6 @@ assert_cc(EAGAIN == EWOULDBLOCK);
int saved_argc = 0;
char **saved_argv = NULL;
-static volatile unsigned cached_columns = 0;
-static volatile unsigned cached_lines = 0;
-
size_t page_size(void) {
static thread_local size_t pgsz = 0;
long r;
@@ -600,51 +595,6 @@ bool hidden_file(const char *filename) {
return hidden_file_allow_backup(filename);
}
-int open_terminal(const char *name, int mode) {
- int fd, r;
- unsigned c = 0;
-
- /*
- * If a TTY is in the process of being closed opening it might
- * cause EIO. This is horribly awful, but unlikely to be
- * changed in the kernel. Hence we work around this problem by
- * retrying a couple of times.
- *
- * https://bugs.launchpad.net/ubuntu/+source/linux/+bug/554172/comments/245
- */
-
- assert(!(mode & O_CREAT));
-
- for (;;) {
- fd = open(name, mode, 0);
- if (fd >= 0)
- break;
-
- if (errno != EIO)
- return -errno;
-
- /* Max 1s in total */
- if (c >= 20)
- return -errno;
-
- usleep(50 * USEC_PER_MSEC);
- c++;
- }
-
- r = isatty(fd);
- if (r < 0) {
- safe_close(fd);
- return -errno;
- }
-
- if (!r) {
- safe_close(fd);
- return -ENOTTY;
- }
-
- return fd;
-}
-
int flush_fd(int fd) {
struct pollfd pollfd = {
.fd = fd,