]> Sergey Matveev's repositories - nnn.git/commitdiff
Always detach opener
authorArun Prakash Jana <engineerarun@gmail.com>
Fri, 26 Apr 2019 03:16:37 +0000 (08:46 +0530)
committerArun Prakash Jana <engineerarun@gmail.com>
Fri, 26 Apr 2019 03:16:57 +0000 (08:46 +0530)
This may affect issue #227 but the defunct processes do not use any memory and exit when nnn exits. I guess that happens because of xdg-open using an intermediate script.

However, if we do not detach xdg-open, the child process is killed when the terminal is closed which is a severe problem.

README.md
nnn.1
src/nnn.c

index 5e706127317096c2c57f913f7ef45867d191f49a..63f404bb664efb3d76931c6d394269213949be5a 100644 (file)
--- a/README.md
+++ b/README.md
@@ -335,7 +335,6 @@ The following indicators are used in the detail view:
 | --- | --- |
 | `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) |
 | `NNN_OPENER=mimeopen` | custom file opener |
-| `NNN_OPENER_DETACH=1` | do not block when invoking file opener |
 | `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
 | `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] |
 | `NNN_COPIER='/absolute/path/to/copier'` | system clipboard copier script [default: none] |
diff --git a/nnn.1 b/nnn.1
index 95400b662c0d578536aba5b9d25d19603264bab4..3d66c93ebd14d8c1a8c2868cc0e57802e1cf14a2 100644 (file)
--- a/nnn.1
+++ b/nnn.1
@@ -154,11 +154,6 @@ when dealing with the !, e and p commands respectively. A single combination to
     export NNN_OPENER=mimeopen
 .Ed
 .Pp
-\fBNNN_OPENER_DETACH:\fR do not block when invoking file opener.
-.Bd -literal
-    export NNN_OPENER_DETACH=1
-.Ed
-.Pp
 \fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.:
 .Bd -literal
     export NNN_CONTEXT_COLORS='1234'
index d154406091442826511bb6b9b582b7d634094b01..d28e43539f141474a4c2b2396d3e34d45910e0d8 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -291,7 +291,6 @@ static bm bookmark[BM_MAX];
 static size_t g_tmpfplen;
 static uchar g_crc;
 static uchar BLK_SHIFT = 9;
-static uchar opener_flag = F_NOTRACE;
 static bool interrupted = FALSE;
 
 /* Retain old signal handlers */
@@ -392,10 +391,9 @@ static const char * const messages[] = {
 #define NNN_NO_AUTOSELECT 9
 #define NNN_RESTRICT_NAV_OPEN 10
 #define NNN_RESTRICT_0B 11
-#define NNN_OPENER_DETACH 12
-#define NNN_TRASH 13
+#define NNN_TRASH 12
 #ifdef __linux__
-#define NNN_OPS_PROG 14
+#define NNN_OPS_PROG 13
 #endif
 
 static const char * const env_cfg[] = {
@@ -411,7 +409,6 @@ static const char * const env_cfg[] = {
        "NNN_NO_AUTOSELECT",
        "NNN_RESTRICT_NAV_OPEN",
        "NNN_RESTRICT_0B",
-       "NNN_OPENER_DETACH",
        "NNN_TRASH",
 #ifdef __linux__
        "NNN_OPS_PROG",
@@ -3151,7 +3148,7 @@ nochange:
                                }
 
                                /* Invoke desktop opener as last resort */
-                               spawn(opener, newpath, NULL, NULL, opener_flag);
+                               spawn(opener, newpath, NULL, NULL, F_NOTRACE | F_NOWAIT);
                                continue;
                        }
                        default:
@@ -4276,8 +4273,6 @@ int main(int argc, char *argv[])
 
        /* Get custom opener, if set */
        opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]);
-       if (xgetenv_set(env_cfg[NNN_OPENER_DETACH]))
-               opener_flag |= F_NOWAIT;
        DPRINTF_S(opener);
 
        /* Parse bookmarks string */
@@ -4321,7 +4316,7 @@ int main(int argc, char *argv[])
                }
 
                if (S_ISREG(sb.st_mode)) {
-                       spawn(opener, initpath, NULL, NULL, opener_flag);
+                       spawn(opener, initpath, NULL, NULL, F_NOTRACE | F_NOWAIT);
                        return 0;
                }
        }