diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-05-15 17:25:08 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-05-15 17:25:08 +0200 |
commit | 843d2643849a1ec63034012c8fe50bfaad23190b (patch) | |
tree | c073b19d9eb4a164b41c70e60fdcbd2d5e9b9bbf /util.c | |
parent | d9a76d8f860c4ee19c4aa0df685889d058f4c5cb (diff) |
log: rework logging logic so that we don't keep /dev/console open
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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", |