]> Sergey Matveev's repositories - nnn.git/commitdiff
Change debug file name, close before exit
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 15 Mar 2019 16:39:27 +0000 (22:09 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 15 Mar 2019 16:48:14 +0000 (22:18 +0530)
src/nnn.c

index a817ccefe20348016367bb96c4b78c0006101f82..87a3e4c16a83c6cf24668b5a421c67a12f2b21f1 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -121,21 +121,22 @@ xprintf(int fd, const char *fmt, ...)
 static int
 enabledbg()
 {
-       FILE *fp = fopen("/tmp/nnn_debug", "w");
+       FILE *fp = fopen("/tmp/nnndbg", "w");
 
        if (!fp) {
-               fprintf(stderr, "debug: open failed! (1)\n");
+               perror("dbg(1)");
 
-               fp = fopen("./nnn_debug", "w");
+               fp = fopen("./nnndbg", "w");
                if (!fp) {
-                       fprintf(stderr, "debug: open failed! (2)\n");
+                       perror("dbg(2)");
                        return -1;
                }
        }
 
-       DEBUG_FD = fileno(fp);
+       DEBUG_FD = dup(fileno(fp));
+       fclose(fp);
        if (DEBUG_FD == -1) {
-               fprintf(stderr, "debug: open fd failed!\n");
+               perror("dbg(3)");
                return -1;
        }