aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-03-15 22:09:27 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2019-03-15 22:18:14 +0530
commitcdc7d81b60028c1416d4e5637e7ff8dee0c589e8 (patch)
tree47f16cd6fff1c661f8f202cfdf14772b9fa501bb /src
parent4d6ec9c47528cccc418f8587529de2ee4af3640d (diff)
downloadnnn-cdc7d81b60028c1416d4e5637e7ff8dee0c589e8.tar.gz
Change debug file name, close before exit
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nnn.c b/src/nnn.c
index a817cce..87a3e4c 100644
--- 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;
}