summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-15 17:25:08 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-15 17:25:08 +0200
commit843d2643849a1ec63034012c8fe50bfaad23190b (patch)
treec073b19d9eb4a164b41c70e60fdcbd2d5e9b9bbf /util.c
parentd9a76d8f860c4ee19c4aa0df685889d058f4c5cb (diff)
log: rework logging logic so that we don't keep /dev/console open
Diffstat (limited to 'util.c')
-rw-r--r--util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.c b/util.c
index f8b3f44ad1..5df811d038 100644
--- a/util.c
+++ b/util.c
@@ -1890,6 +1890,24 @@ int parse_usec(const char *t, usec_t *usec) {
return 0;
}
+int make_stdio(int fd) {
+ int r, s, t;
+
+ assert(fd >= 0);
+
+ r = dup2(fd, STDIN_FILENO);
+ s = dup2(fd, STDOUT_FILENO);
+ t = dup2(fd, STDERR_FILENO);
+
+ if (fd >= 3)
+ close_nointr_nofail(fd);
+
+ if (r < 0 || s < 0 || t < 0)
+ return -errno;
+
+ return 0;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",