]> Sergey Matveev's repositories - nnn.git/commitdiff
Fix frozen terminal
authorKlzXS <klzx+github@klzx.cf>
Tue, 16 Feb 2021 22:23:29 +0000 (22:23 +0000)
committerKlzXS <klzx+github@klzx.cf>
Tue, 16 Feb 2021 22:33:09 +0000 (22:33 +0000)
xdg-open would launch a cli program that would contest the terminal for character input

src/nnn.c

index e8b98de900265001c04278c02f9d962dd7547c9b..4e5685c72550329823e0d8d5cceb780c43b217dd 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
 #define F_NORMAL  0x08  /* spawn child process in non-curses regular CLI mode */
 #define F_CONFIRM 0x10  /* run command - show results before exit (must have F_NORMAL) */
 #define F_CHKRTN  0x20  /* wait for user prompt if cmd returns failure status */
+#define F_ALLNULL 0x44  /* stdin, stdout and stderr mapped to /dev/null */
 #define F_CLI     (F_NORMAL | F_MULTI)
 #define F_SILENT  (F_CLI | F_NOTRACE)
 
@@ -1910,6 +1911,8 @@ static int spawn(char *file, char *arg1, char *arg2, uchar_t flag)
                if (flag & F_NOTRACE) {
                        int fd = open("/dev/null", O_WRONLY, 0200);
 
+                       if (flag & F_ALLNULL)
+                               dup2(fd, 0);
                        dup2(fd, 1);
                        dup2(fd, 2);
                        close(fd);