mirror of
https://github.com/jarun/nnn.git
synced 2025-03-14 10:44:05 +00:00
Change debug file name, close before exit
This commit is contained in:
parent
4d6ec9c475
commit
cdc7d81b60
1 changed files with 7 additions and 6 deletions
13
src/nnn.c
13
src/nnn.c
|
@ -121,21 +121,22 @@ xprintf(int fd, const char *fmt, ...)
|
||||||
static int
|
static int
|
||||||
enabledbg()
|
enabledbg()
|
||||||
{
|
{
|
||||||
FILE *fp = fopen("/tmp/nnn_debug", "w");
|
FILE *fp = fopen("/tmp/nnndbg", "w");
|
||||||
|
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "debug: open failed! (1)\n");
|
perror("dbg(1)");
|
||||||
|
|
||||||
fp = fopen("./nnn_debug", "w");
|
fp = fopen("./nnndbg", "w");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
fprintf(stderr, "debug: open failed! (2)\n");
|
perror("dbg(2)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_FD = fileno(fp);
|
DEBUG_FD = dup(fileno(fp));
|
||||||
|
fclose(fp);
|
||||||
if (DEBUG_FD == -1) {
|
if (DEBUG_FD == -1) {
|
||||||
fprintf(stderr, "debug: open fd failed!\n");
|
perror("dbg(3)");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue