Marco,

Corinna reported a failure of mc to open a FIFO when it is run under tcsh.  See

   https://cygwin.com/ml/cygwin/2019-12/msg00185.html

and my response.  To summarize, mc tries to open a FIFO as O_RDWR twice, and 
this fails because Cygwin's FIFO implementation currently allows only one 
reader 
(but multiple writers).  As a result, mc doesn't use a subshell when it is run 
under tcsh.

There is a simple fix for the problem (attached).  Unfortunately, when I apply 
this fix, mc is very slow to start up (about 10 seconds on my system) under 
tcsh.  I'm not a tcsh user, but I simply ran 'tcsh -l' and then 'mc'.  I have 
no 
tcsh or csh startup files in my home directory.

Running mc under strace shows that the forked tcsh subshell lists every 
directory in my PATH.  The strace output shows that the subshell calls readdir 
more than 77,000 times.  By contrast, the bash subshell doesn't call readdir at 
all when I run mc under bash.

I hope someone more familiar with tcsh can explain this and provide a 
workaround.  Otherwise, I think the fix is probably useless.

Ken
--- origsrc/mc-4.8.23/src/subshell/common.c     2019-06-16 13:49:31.000000000 
-0400
+++ src/mc-4.8.23/src/subshell/common.c 2019-12-22 20:44:43.781884100 -0500
@@ -1071,10 +1071,10 @@ init_subshell (void)
                 return;
             }
 
-            /* Opening the FIFO as O_RDONLY or O_WRONLY causes deadlock */
+            /* Open the FIFO first as O_RDWR to avoid deadlock */
 
             if ((subshell_pipe[READ] = open (tcsh_fifo, O_RDWR)) == -1
-                || (subshell_pipe[WRITE] = open (tcsh_fifo, O_RDWR)) == -1)
+                || (subshell_pipe[WRITE] = open (tcsh_fifo, O_WRONLY)) == -1)
             {
                 fprintf (stderr, _("Cannot open named pipe %s\n"), tcsh_fifo);
                 perror (__FILE__ ": open");

Reply via email to