* Possible fix for Midnight Commander FIFO problem under tcsh
@ 2019-12-23 20:57 Ken Brown
0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2019-12-23 20:57 UTC (permalink / raw)
To: cygwin-apps
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
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
[-- Attachment #2: 4.8.23-fifo.patch --]
[-- Type: text/plain, Size: 771 bytes --]
--- 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");
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-23 20:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-23 20:57 Possible fix for Midnight Commander FIFO problem under tcsh Ken Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).