Mail Archives: cygwin/2005/12/05/01:23:28
I was writing some code to experiment with parallel writes to a named
fifo, with a reader daemon constantly running in the background. The
situation works fine as long as only a single writer executes at a
time. However, with two or more writers running simultaneously, only
the first will execute, the second will execute but a deadlock will
begin, and the remaining writers will never execute. Moreover, cygwin
seems to either lockup, or become deathly slow. The only way to
recover seems to be to kill the processes using Windows (after which,
the FIFO sometimes deadlocks immediately upon its first use).
Here is code to exercise the problem. It's a simplification of code
out of the Perl Cookbook section on named pipes..
I have tested, and it runs fine under Linux. And yes, on Cygwin the
problem still occurs without the alarm code.
To launch, start the reader daemon. Then, run the following (note the
& used to run the writers simultaneously):
for x in `seq 10`; do (./client.pl $x > logs/$x &); done
::::::::::::::: READER DAEMON ::::::::::::
#!/usr/bin/perl
use IO::File;
$SIG{ALRM} = sub {
close(FIFO)
or warn $! ? "Error closing pipe: $!" : "Exit status
$? from other side";
}; # move on to the next queued process
while (1) {
alarm(0); # turn off alarm for blocking open
open(FIFO, "< /path/to/named.pipe")
or die "Can't open pip : $!\n";
alarm(1); # you have 1 second to log
$service = <FIFO>;
next unless defined $service; # interrupted or nothing logged
print "GOT: [$service]\n";
alarm(0);
}
::::::::::::::: WRITER CLIENTS ::::::::::::
#!/usr/bin/perl
use POSIX qw(:errno_h);
$SIG{PIPE} = 'IGNORE';
open(FIFO, "> /path/to/named.pipe") or die $!;
$status = print FIFO "Smoke this $ARGV[0].\n";
if (!$status && $! == EPIPE) { print "MY READER HAS FORSAKEN ME!\n"; exit(1); }
close(FIFO)
or warn $! ? "Error closing pipe: $!" : "Exit status $? from
other side";
Here is information on my Cygwin environment, which I'm running on XP
SP2 32-bit.
$ mkfifo --version
mkfifo (GNU coreutils) 5.3.0
Written by David MacKenzie.
$ uname -a
CYGWIN_NT-5.1 mark-piper 1.5.18(0.132/4/2) 2005-07-02 20:30 i686 unknown unknown
Cygwin
I realize that named pipe support is new in Cygwin, and look forward
to its maturity. Thanks for all of your great work! If there's any
other information needed, just let me know.
-- Mark Piper
(NOTE: I am not subscribed to the cygwin list, so please CC me on any
correspondance.)
P.S. Here is the full output from cygcheck
$ /bin/cygcheck.exe -s
Cygwin Configuration Diagnostics
Current System Time: Sun Dec 04 22:15:33 2005
Windows XP Professional Ver 5.1 Build 2600 Service Pack 2
Path: C:\cygwin\usr\local\bin
C:\cygwin\bin
C:\cygwin\bin
C:\cygwin\usr\X11R6\bin
c:\Perl\bin\
c:\WINDOWS\system32
c:\WINDOWS
c:\WINDOWS\System32\Wbem
c:\Program Files\ATI Technologies\ATI Control Panel
C:\cygwin\bin
Output from C:\cygwin\bin\id.exe (nontsec)
UID: 1003(Mark Piper) GID: 513(None)
0(root) 513(None) 544(Administrators)
545(Users)
Output from C:\cygwin\bin\id.exe (ntsec)
UID: 1003(Mark Piper) GID: 513(None)
0(root) 513(None) 544(Administrators)
545(Users)
SysDir: C:\WINDOWS\system32
WinDir: C:\WINDOWS
USER = `Mark Piper'
PWD = `/home/Mark Piper/test/simple-fifo'
HOME = `/home/Mark Piper'
MAKE_MODE = `unix'
Use `-r' to scan registry
c: hd NTFS 90600Mb 7% CP CS UN PA FC
d: cd CDFS 4465Mb 100% CS UN Embryo
C:\cygwin / system binmode
C:\cygwin/bin /usr/bin system binmode
C:\cygwin/lib /usr/lib system binmode
. /cygdrive system binmode,cygdrive
Found: C:\cygwin\bin\awk.exe
Found: C:\cygwin\bin\bash.exe
Found: C:\cygwin\bin\cat.exe
Found: C:\cygwin\bin\cp.exe
Not Found: cpp (good!)
Found: C:\cygwin\bin\find.exe
Not Found: gcc
Not Found: gdb
Found: C:\cygwin\bin\grep.exe
Not Found: ld
Found: C:\cygwin\bin\ls.exe
Not Found: make
Found: C:\cygwin\bin\mv.exe
Found: C:\cygwin\bin\rm.exe
Found: C:\cygwin\bin\sed.exe
Found: C:\cygwin\bin\sh.exe
Found: C:\cygwin\bin\tar.exe
56k 2005/07/09 C:\cygwin\bin\cygbz2-1.dll
7k 2005/11/20 C:\cygwin\bin\cygcharset-1.dll
7k 2003/10/19 C:\cygwin\bin\cygcrypt-0.dll
1108k 2005/10/17 C:\cygwin\bin\cygcrypto-0.9.7.dll
1047k 2005/10/11 C:\cygwin\bin\cygcrypto-0.9.8.dll
895k 2004/04/28 C:\cygwin\bin\cygdb-4.2.dll
965k 2005/05/14 C:\cygwin\bin\cygdb-4.3.dll
1156k 2004/04/28 C:\cygwin\bin\cygdb_cxx-4.2.dll
1240k 2005/05/14 C:\cygwin\bin\cygdb_cxx-4.3.dll
174k 2004/10/14 C:\cygwin\bin\cygexpat-0.dll
40k 2005/09/29 C:\cygwin\bin\cygform-8.dll
45k 2001/04/25 C:\cygwin\bin\cygform5.dll
35k 2002/01/09 C:\cygwin\bin\cygform6.dll
48k 2003/08/09 C:\cygwin\bin\cygform7.dll
28k 2003/07/20 C:\cygwin\bin\cyggdbm-3.dll
30k 2003/08/11 C:\cygwin\bin\cyggdbm-4.dll
19k 2003/03/22 C:\cygwin\bin\cyggdbm.dll
15k 2003/07/20 C:\cygwin\bin\cyggdbm_compat-3.dll
15k 2003/08/11 C:\cygwin\bin\cyggdbm_compat-4.dll
17k 2001/06/28 C:\cygwin\bin\cyghistory4.dll
29k 2003/08/10 C:\cygwin\bin\cyghistory5.dll
24k 2005/07/29 C:\cygwin\bin\cyghistory6.dll
947k 2005/11/20 C:\cygwin\bin\cygiconv-2.dll
22k 2001/12/13 C:\cygwin\bin\cygintl-1.dll
37k 2003/08/10 C:\cygwin\bin\cygintl-2.dll
31k 2005/11/20 C:\cygwin\bin\cygintl-3.dll
21k 2001/06/20 C:\cygwin\bin\cygintl.dll
21k 2005/09/29 C:\cygwin\bin\cygmenu-8.dll
26k 2001/04/25 C:\cygwin\bin\cygmenu5.dll
20k 2002/01/09 C:\cygwin\bin\cygmenu6.dll
29k 2003/08/09 C:\cygwin\bin\cygmenu7.dll
21k 2004/10/22 C:\cygwin\bin\cygminires.dll
67k 2005/09/29 C:\cygwin\bin\cygncurses++-8.dll
156k 2001/04/25 C:\cygwin\bin\cygncurses++5.dll
175k 2002/01/09 C:\cygwin\bin\cygncurses++6.dll
226k 2005/09/29 C:\cygwin\bin\cygncurses-8.dll
226k 2001/04/25 C:\cygwin\bin\cygncurses5.dll
202k 2002/01/09 C:\cygwin\bin\cygncurses6.dll
224k 2003/08/09 C:\cygwin\bin\cygncurses7.dll
11k 2005/09/29 C:\cygwin\bin\cygpanel-8.dll
15k 2001/04/25 C:\cygwin\bin\cygpanel5.dll
12k 2002/01/09 C:\cygwin\bin\cygpanel6.dll
19k 2003/08/09 C:\cygwin\bin\cygpanel7.dll
176k 2005/09/06 C:\cygwin\bin\cygpcre-0.dll
299k 2005/09/06 C:\cygwin\bin\cygpcrecpp-0.dll
6k 2005/09/06 C:\cygwin\bin\cygpcreposix-0.dll
1248k 2005/08/22 C:\cygwin\bin\cygperl5_8.dll
22k 2002/06/09 C:\cygwin\bin\cygpopt-0.dll
108k 2001/06/28 C:\cygwin\bin\cygreadline4.dll
148k 2003/08/10 C:\cygwin\bin\cygreadline5.dll
144k 2005/07/29 C:\cygwin\bin\cygreadline6.dll
231k 2005/10/17 C:\cygwin\bin\cygssl-0.9.7.dll
215k 2005/10/11 C:\cygwin\bin\cygssl-0.9.8.dll
65k 2005/08/23 C:\cygwin\bin\cygz.dll
1265k 2005/07/03 C:\cygwin\bin\cygwin1.dll
Cygwin DLL version info:
DLL version: 1.5.18
DLL epoch: 19
DLL bad signal mask: 19005
DLL old termios: 5
DLL malloc env: 28
API major: 0
API minor: 132
Shared data: 4
DLL identifier: cygwin1
Mount /usr/bin/cygrunsrv: Exactly one of --install, --remove,
--start, --stop, --query, or --list is required
Try `/usr/bin/cygrunsrv --help' for more information.
registry: 2
Cygnus registry name: Cygnus Solutions
Cygwin registry name: Cygwin
Program options name: Program Options
Cygwin mount registry name: mounts v2
Cygdrive flags: cygdrive flags
Cygdrive prefix: cygdrive prefix
Cygdrive default prefix:
Build date: Sat Jul 2 20:30:04 EDT 2005
Shared id: cygwin1S4
Service : sshd
Display name : CYGWIN sshd
Current State : Running
Controls Accepted : Stop
Command : /usr/sbin/sshd -D
Cygwin Package Information
Package Version
_update-info-dir 00333-1
alternatives 1.3.20a-2
ash 20040127-3
base-files 3.6-1
base-passwd 2.2-1
bash 3.0-11
bzip2 1.0.3-1
coreutils 5.3.0-9
crypt 1.1-1
cygrunsrv 1.12-1
cygutils 1.2.9-1
cygwin 1.5.18-1
cygwin-doc 1.4-3
diffutils 2.8.7-1
editrights 1.01-1
expat 1.95.8-1
findutils 4.2.25-2
gawk 3.1.5-2
gdbm 1.8.3-7
grep 2.5.1a-2
groff 1.18.1-2
gzip 1.3.5-1
less 381-1
libbz2_1 1.0.3-1
libcharset1 1.9.2-2
libdb4.2 4.2.52-1
libdb4.3 4.3.28-1
libgdbm 1.8.0-5
libgdbm-devel 1.8.3-7
libgdbm3 1.8.3-3
libgdbm4 1.8.3-7
libiconv 1.9.2-2
libiconv2 1.9.2-2
libintl 0.10.38-3
libintl1 0.10.40-1
libintl2 0.12.1-3
libintl3 0.14.5-1
libncurses5 5.2-1
libncurses6 5.2-8
libncurses7 5.3-4
libncurses8 5.4-4
libpcre0 6.3-1
libpopt0 1.6.4-4
libreadline4 4.1-2
libreadline5 4.3-5
libreadline6 5.0-4
login 1.9-7
man 1.5p-1
minires 1.00-1
mktemp 1.5-3
ncurses 5.4-4
openssh 4.2p1-1
openssl 0.9.8a-1
openssl097 0.9.7i-1
perl 5.8.7-4
perl_manpages 5.8.7-4
procps 3.2.5-1
psmisc 21.5-1
run 1.1.6-1
sed 4.1.4-1
tar 1.15.1-2
termcap 20050421-1
terminfo 5.4_20041009-1
texinfo 4.8-1
which 1.7-1
zlib 1.2.3-1
Use -h to see help about each section
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -