Hi Ken,
On Mon, 18 May 2020 13:42:19 -0400
Ken Brown via Cygwin-patches <[email protected]> wrote:
> Hi Takashi,
>
> On 5/18/2020 12:03 PM, Ken Brown via Cygwin-patches wrote:
> > On 5/18/2020 1:36 AM, Takashi Yano via Cygwin-patches wrote:
> >> On Mon, 18 May 2020 14:25:19 +0900
> >> Takashi Yano via Cygwin-patches <[email protected]> wrote:
> >>> However, mc hangs by several operations.
> >>>
> >>> To reproduce this:
> >>> 1. Start mc with 'env SHELL=tcsh mc -a'
> >>
> >> I mean 'env SHELL=/bin/tcsh mc -a'
> >>
> >>> 2. Select a file using up/down cursor keys.
> >>> 3. Press F3 (View) key.
> >
> > Thanks for the report. I can reproduce the problem and will look into it.
>
> I'm not convinced that this is a FIFO bug. I tried two things.
>
> 1. I attached gdb to mc while it was hanging and got the following backtrace
> (abbreviated):
>
> #1 0x00007ff901638037 in WaitForMultipleObjectsEx ()
> #2 0x00007ff901637f1e in WaitForMultipleObjects ()
> #3 0x0000000180048df5 in cygwait () at ...winsup/cygwin/cygwait.cc:75
> #4 0x000000018019b1c0 in wait4 () at ...winsup/cygwin/wait.cc:80
> #5 0x000000018019afea in waitpid () at ...winsup/cygwin/wait.cc:28
> #6 0x000000018017d2d8 in pclose () at ...winsup/cygwin/syscalls.cc:4627
> #7 0x000000018015943b in _sigfe () at sigfe.s:35
> #8 0x000000010040d002 in get_popen_information () at filemanager/ext.c:561
> [...]
>
> So pclose is blocking after calling waitpid. As far as I can tell from
> looking
> at backtraces of all threads, there are no FIFOs open.
>
> 2. I ran mc under strace (after exporting SHELL=/bin/tcsh), and I didn't see
> anything suspicious involving FIFOs. But I saw many EBADF errors from fstat
> and
> close that don't appear to be related to FIFOs.
>
> So my best guess at this point is that the FIFO changes just exposed some
> unrelated bug(s).
>
> Prior to the FIFO changes, mc would get an error when it tried to open
> tcsh_fifo
> the second time, and it would then set
>
> mc_global.tty.use_subshell = FALSE;
>
> see the mc source file subshell/common.c:1087.
I looked into this problem and found pclose() stucks if FIFO
is opened.
Attached is a simple test case. It works under cygwin 3.1.4,
but stucks at pclose() under cygwin git head.
Isn't this a FIFO related issue?
--
Takashi Yano <[email protected]>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fifo;
FILE *p;
int r;
printf("Call mkfifo().\n");
r = mkfifo("fifo1", 0600);
if (r == 0) printf("mkfifo() success.\n");
printf("Call open().\n");
fifo = open("fifo1", O_RDWR);
if (fifo != -1) printf("open() success.\n");
printf("Call popen().\n");
p = popen("/bin/true", "r");
if (p) printf("popen() success.\n");
printf("Call pclose().\n");
r = pclose(p);
if (r != -1) printf("pclose() success.\n");
printf("Call close().\n");
r = close(fifo);
if (r == 0) printf("close() success.\n");
printf("Call unlink().\n");
r = unlink("fifo1");
if (r == 0) printf("unlink() success.\n");
return 0;
}