public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* GNU coreutils does not work on Cygwin because of freopen() ?
@ 2009-01-18 21:21 dazjorz
  2009-01-18 22:19 ` Dave Korn
  0 siblings, 1 reply; 12+ messages in thread
From: dazjorz @ 2009-01-18 21:21 UTC (permalink / raw)
  To: cygwin; +Cc: Ed Schouten

Hey all,

I'm not very great with the inner workings of GNU or Cygwin libc, so 
please bear with me if I make any mistakes or misunderstandings.

I was trying to get GNU coreutils to work on Cygwin. Maybe this seems 
weird to you guys, because Cygwin has coreutils, but there are a few 
reasons:
- Cygwin didn't have md5sum, GNU coreutils did (and I need md5sum)
- It should work, and "Because I Can" is always a valid reason in UNIX world
- I'm trying to bootstrap Debian on Cygwin, and coreutils from Debian is 
my first try; getting coreutils from Cygwin may be done later.

However, I noticed there are some very weird bugs happening. See for 
example, this bug in cat (don't look at the title of the page, I blamed 
bash first)
http://paster.dazjorz.com/?p=3845

A friend of mine and me have been trying to figure out what causes this. 
First, we tested if it wasn't a bug in open() + fork(). This seemed not 
to be the case. So we started looking further, and we're down to GNU 
`cat` calling freopen(). This is not POSIX-compliant and can cause 
problems like this.

`cat` and other coreutils tools only call freopen() if O_BINARY is 
defined on this platform. It's defined on Cygwin, because Cygwin makes a 
difference between O_TEXT and O_BINARY.

1. Why does Cygwin distinguish between O_TEXT and O_BINARY? Shouldn't 
this difference be removed from the Linux API side of Cygwin?
2. I don't know why coreutils is calling freopen() at all. Should I 
patch it out completely, or add something like an #ifndef __CYGWIN__ 
around the pieces of code in question?

I'm hesitant to patch coreutils, so I'm asking for your opinion first.

Thanks for any replies,
Sjors

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

^ permalink raw reply	[flat|nested] 12+ messages in thread
* GNU coreutils does not work on Cygwin because of freopen() ?
@ 2009-01-18 21:25 dazjorz
  2009-01-18 21:37 ` Larry Hall (Cygwin)
  0 siblings, 1 reply; 12+ messages in thread
From: dazjorz @ 2009-01-18 21:25 UTC (permalink / raw)
  To: cygwin

Hey all,

I'm not very great with the inner workings of GNU or Cygwin libc, so 
please bear with me if I make any mistakes or misunderstandings.

I was trying to get GNU coreutils to work on Cygwin. Maybe this seems 
weird to you guys, because Cygwin has coreutils, but there are a few 
reasons:
- Cygwin didn't have md5sum, GNU coreutils did (and I need md5sum)
- It should work, and "Because I Can" is always a valid reason in UNIX world
- I'm trying to bootstrap Debian on Cygwin, and coreutils from Debian is 
my first try; getting coreutils from Cygwin may be done later.

However, I noticed there are some very weird bugs happening. See for 
example, this bug in cat (don't look at the title of the page, I blamed 
bash first)
http://paster.dazjorz.com/?p=3845

A friend of mine and me have been trying to figure out what causes this. 
First, we tested if it wasn't a bug in open() + fork(). This seemed not 
to be the case. So we started looking further, and we're down to GNU 
`cat` calling freopen(). This is not POSIX-compliant and can cause 
problems like this.

`cat` and other coreutils tools only call freopen() if O_BINARY is 
defined on this platform. It's defined on Cygwin, because Cygwin makes a 
difference between O_TEXT and O_BINARY.

1. Why does Cygwin distinguish between O_TEXT and O_BINARY? Shouldn't 
this difference be removed from the Linux API side of Cygwin?
2. I don't know why coreutils is calling freopen() at all. Should I 
patch it out completely, or add something like an #ifndef __CYGWIN__ 
around the pieces of code in question?

I'm hesitant to patch coreutils, so I'm asking for your opinion first.

Thanks for any replies,
Sjors

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-01-18 22:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-18 21:21 GNU coreutils does not work on Cygwin because of freopen() ? dazjorz
2009-01-18 22:19 ` Dave Korn
2009-01-19  2:42   ` Eric Blake
2009-01-18 21:25 dazjorz
2009-01-18 21:37 ` Larry Hall (Cygwin)
2009-01-18 21:42   ` Sjors Gielen
2009-01-18 22:19     ` Yaakov (Cygwin/X)
2009-01-18 22:22       ` Sjors Gielen
2009-01-18 22:26         ` Matt Wozniski
2009-01-18 22:29         ` Ed Schouten
2009-01-19  2:16           ` Eric Blake
2009-01-18 23:52         ` Eric Blake

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).