This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: man - broken pipe [Attn: man maintainer]


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Brian Dessent on 7/20/2005 2:52 AM:
> I think it would depend on what packages you upgraded.  It could be that
> the default buffer size somewhere has changed.  If it was quite large to
> begin with, and then was reduced, you would see the error more often.  I
> don't think the SIGPIPE behavior itself has changed, it has always been
> the case that a writer to a broken pipe receives the signal.  But it can
> be kind of racey if both the writer and reader are exiting.  Or, it
> could be that bash 2.x supressed that message while bash 3.x doesn't.

The pipe buffer sizes did not change (those are controlled by
cygwin1.dll).  But yes, if you look at /usr/share/doc/bash-3.0/CHANGES,
note this line:

nnn. The shell now reports on processes that dump core due to signals when
     invoked as `-c command'.

man uses the system() call, which indeed invokes /bin/sh (now bash) as `-c
command'.  In particular, the command being passed can be determined by
`man -d'; in the case of g++, command is (more or less):

'(cd /usr/share/man && (echo ".pl 1100i"; /usr/bin/gunzip -c
/usr/share/man/man1/g++.1.gz ;echo ".\\\""; echo ".pl \n(nlu+10")
|/usr/bin/tbl |/usr/binnroff -c -mandoc 2>/dev/null |less -s)'

OK, so gunzip didn't really dump core, but it does die due to a signal
(SIGPIPE) when not all of its output is read by less, and bash (aka
/bin/sh) is running it as -c command, hence the warning.

Now here's where the man maintainer might be able to help.  By changing
the command that gets passed to bash, you can tell bash to ignore SIGPIPE
(which gets inherited to all child processes).  This stops the SIGPIPE,
but instead gives the error EPIPE when gunzip tries to write to stdout,
which gunzip warns us about on stderr.  So we also need to ignore gunzip's
warning.  In other words, if man were to attempt this command, the error
message disappears!

'(cd /usr/share/man && (trap "" PIPE; echo ".pl 1100i"; /usr/bin/gunzip -c
/usr/share/man/man1/g++.1.gz ;echo ".\\\""; echo ".pl \n(nlu+10")
2>/dev/null |/usr/bin/tbl |/usr/binnroff -c -mandoc 2>/dev/null |less -s)'

But I don't know enough about man to figure out how to add 'trap "" PIPE;'
and the first '2>/dev/null' into the attempted command.  And this will
probably affect man installations on other platforms, so it may be worth
reporting upstream.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC3kl084KuGfSFAYARAoGQAKCgv7rQYXAq1wTCWp/t8acjPvBJNQCgywuG
qD1bvWgs9VlsWmae2iWKQKM=
=cEz+
-----END PGP SIGNATURE-----

--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]