ltk

Socket-based GUI for X11 (WIP)
git clone git://lumidify.org/ltk.git (fast, but not encrypted)
git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
Log | Files | Refs | README | LICENSE

commit b411a0c6e0d45f347be63ffb40dc62092ab8c3c1
parent 6b197acfae171f5db4ef485cf5fc503287c52752
Author: lumidify <nobody@lumidify.org>
Date:   Sat, 30 Jan 2021 20:20:23 +0100

Redirect stdout and stderr to logfile

Diffstat:
Mltkd.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/ltkd.c b/ltkd.c @@ -302,12 +302,16 @@ daemonize(void) { if (chdir("/") < 0) ltk_fatal_errno("Can't change directory to root.\n"); + /* FIXME: why didn't I just use fclose() here? */ + /* FIXME: just print log to stdout and let this take care of redirection */ close(fileno(stdin)); - close(fileno(stdout)); - close(fileno(stderr)); + /*close(fileno(stdout)); + close(fileno(stderr));*/ open("/dev/null", O_RDWR); - dup(0); - dup(0); + /*dup(0); + dup(0);*/ + dup2(fileno(ltk_logfile), fileno(stdout)); + dup2(fileno(ltk_logfile), fileno(stderr)); /* FIXME: Is it guaranteed that this will work? Will these fds always be opened on the lowest numbers? */