Cygwin的替代方案? - Cygwin不支持本地支持Win32应用程序 [英] Good alternatives to Cygwin? - Cygwin doesn't support natively support Win32 apps

查看:185
本文介绍了Cygwin的替代方案? - Cygwin不支持本地支持Win32应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Update 1/9/2014:TL; DR version:转到此帖的底部,以获得Cygwin能够调用非Cygwin程序的方法。

Update 1/9/2014: TL;DR version: Go to bottom of this post for a way to get Cygwin to be able to call non-Cygwin programs.

在花了一些时间来制作一些大小相当的bash脚本之后,新版本的Cygwin已经破坏了它们。这些脚本调用了不与Cygwin链接的本地Win32应用程序,这显然不是Cygwin官方支持的。

After having spent the time to make some bash scripts that happen to be of significant size, newer versions of Cygwin have broken them. These scripts call into native Win32 applications that don't link with Cygwin, which is apparently not officially supported by Cygwin.

这对我来说是一个惊喜,因为年我的印象是,Cygwin可以在更混合的环境中使用,结合本机非Cygwin Win32应用程序和使用Cygwin兼容性层的POSIX程序。但显然只有POSIX兼容层是真正支持的,如果本机Win32非Cygwin应用程序工作,那么它被认为是一个快乐的巧合。

This has come as a surprise to me, as for years I was under the impression that Cygwin could be used in a more mixed environment that combines both native non-Cygwin Win32 apps, and POSIX programs using the Cygwin compatibility layer. But apparently only the POSIX compatibility layer is really supported, and if native Win32 non-Cygwin apps work then it is considered a happy coincidence.

我发现这是由不兼容我遇到了运行程序编译的.NET框架从Cygwin内。这以前工作正常,但几个月前破了。具体来说,来自.NET程序的标准输出通过管道传递到任何其他Win32程序的标准输入,通常会导致接收Win32程序获得一个过早的文件结束信号,因为Cygwin最近在几个月前从字节管道切换到消息管道 - 和消息管道似乎与使用Visual C ++或.NET Framework的任何接收应用程序不兼容。这是因为.NET对标准输出发出了一个空写,只有在使用消息管道时,才会将其传递给接收应用程序。接收应用程序成功读取零字节,因此认为它是文件结束。项目领导似乎不认为这是一个真正的问题,因为他们显然不真正支持从Cygwin内部运行非Cygwin程序(惊喜!)。

I found this out from an incompatibility I ran into with running programs compiled against the .NET Framework from within Cygwin. This used to work fine, but was broken a few months ago. Specifically, standard output from a .NET program that is piped to any other Win32 program's standard input will generally cause the receiving Win32 program to get a premature end-of-file signal because Cygwin recently switched to message pipes from byte pipes a few months ago - and message pipes appear to be incompatible with any receiving app using Visual C++ or .NET Framework. This is because .NET issues a null write to the standard output, which is only passed on to the receiving app if a message pipe is used. The receiving app successfully reads zero bytes, so thinks it is end-of-file. The project lead doesn't appear to consider this to be a real problem, since they apparently don't really support running non-Cygwin programs from within Cygwin (surprise!).

引用项目导致Christopher Faylor从邮件列表上的多封电子邮件:

To quote the project lead Christopher Faylor from multiple e-mails on the mailing list:


您看到的可能是因为Cygwin是更改为使用
消息类型管道几个修订前。这不会改变
。这个改变被用来修复Cygwin程序
的问题,这显然是我们的首要任务。

What you are seeing may be because Cygwin was changed to use message-type pipes a couple of revisions ago. This is not going to change. The change was adopted to fix a problem with Cygwin programs and those are obviously our #1 priority.

无论有多少人使用Visual C ++或.NET他们真的
不是我们的目标受众。当事情为那些
不想使用UNIX工具但他们不是我们的主要焦点的人工作是很好。
解决问题的人谁想要使用非Cygwin的东西不是
的东西,我觉得高优先级。

Regardless of how many people use Visual C++ or .NET they are really not our target audience. It's nice when things work for people who don't want to use UNIX tools but they are not our primary focus. Fixing problems for people who want to use non-Cygwin stuff is not something that I find a high priority.

从pipe.cc:请注意,管道的写入端作为PIPE_TYPE_MESSAGE打开。
这似乎更接近地模仿Linux管道行为,并且
绝对需要pty处理,因为fhandler_pty_master将
写入块中的管道,当CANON模式是
指定的。

From pipe.cc: Note that the write side of the pipe is opened as PIPE_TYPE_MESSAGE. This seems to more closely mimic Linux pipe behavior and is definitely required for pty handling since fhandler_pty_master writes to the pipe in chunks, terminated by newline when CANON mode is specified.

以上注释在此处显示了和关系。消息类型
管道更接近地模仿Linux(UNIX)管道行为,并且绝对是ptys所需的

The above comment shows an "and" relationship here. Message type pipes more closely mimic Linux (UNIX) pipe behavior AND are definitely required for ptys.


同意詹姆斯的运行时可能是buggy但是我也
同意cygwin应该能够处理这些情况。

I agree with James that the runtimes are probably buggy BUT I also agree that cygwin should be able to have a handle these scenarios.

您之间的完全协议不会有太多的
效果。 Cygwin源代码不会被投票更改。

Your complete agreement with each other is not going to have much effect. Cygwin source code is not changed by voting.

即使这一个问题最终固定在某种程度上 - 在3个月,不关心解决回归。他们可能会考虑一个补丁,但它需要我很长时间才能找出一些有效的。我认为我的时间更好地花在别处,因为它很清楚,他们愿意打破与原生Win32应用程序的兼容性,不想浪费更多的时间来获得Win32应用程序的工作。所以我想Cygwin不应该被认为是混合Win32 / Cygwin环境的稳定平台 - 我的替代品是什么?我应该从哪里开始,避免完全重写到除了bash之外的东西?我不使用多于基本的Cygwin安装+一些基本的perl脚本。

Even if this one issue is ultimately fixed somehow - who knows - they might break something else in 3 months and not care to fix the regression. They might consider a patch, but it would take me quite awhile to figure out something that works. I think my time is better spent elsewhere, because it's clear that they are quite willing to break compatibility with native Win32 apps and don't want to waste more time on getting Win32 apps to work. So I guess Cygwin shouldn't be considered a stable platform for mixed Win32/Cygwin environments - what are my alternatives? Where should I start that would avoid a complete rewrite into something other than bash? I don't use more than the base Cygwin installation + some basic perl scripts.

UPDATE:发布这个原始问题后,在 CYGWIN 环境变量中最终创建了一个新的 pipe_byte 标志:查看文档。如果这个标志被设置,它将解决上面讨论的问题。当调用非Cygwin Win32程序时,总是确保设置了 pipe_byte 标志。

UPDATE: After the posting of this original question, they did eventually a new pipe_byte flag in the CYGWIN environment variable: look at the documentation. If this flag is set, it will fix the problem discussed above. When invoking a non-Cygwin Win32 program, always make sure that the pipe_byte flag is set.

但是,我已经发现了与.NET Framework 4.0和Cygwin不兼容。以前的.NET Framework版本没有此问题。我在Cygwin邮件列表上首先提到了这个问题:

However, I have since uncovered an incompatibility with .NET Framework 4.0 and Cygwin. Previous versions of .NET Framework don't have this issue. I mentioned the issue first on the Cygwin mailing list here:

管道同步和Cygwin与.NET Framework 4.0之间的不兼容

没有收到任何有效的回应,我进一步调查,发现Cygwin正在创建重叠的管道,这会导致问题。注意,试图用重叠的管道使用非重叠Win32 API调用是未定义的,并且大多数(所有?)Win32非Cygwin程序不使用重叠I / O及其标准文件句柄。我提交了一个补丁,它在 CYGWIN 环境变量中创建了一个 pipe_nooverlap 标志,防止发生这种情况:

Getting no fruitful responses, I investigated further and found that Cygwin is creating overlapped pipes, which causes the problem. Note that trying to use non-overlapped Win32 API calls with an overlapped pipe is undefined, and most (all?) Win32 non-Cygwin programs don't use overlapped I/O with their standard file handles. I submitted a patch that creates a pipe_nooverlap flag in the CYGWIN environment variable that prevents this from happening:

修补程序可选择禁用重叠管道

不幸的是,他们拒绝了补丁,所以你不会在Cygwin主DLL中看到这个:

Unfortunately, they have rejected the patch, so you'll never see this in the main Cygwin DLL:

Re:Patch可选择停用重叠的管道

拒绝补丁的原因:


  1. 这意味着我打破了在Cygwin中的信号实现;我没有发现这是情况,因为信号仍然使用重叠的管道。

  2. 他们不喜欢添加环境变量标志,即使它显然修复问题。 li>
  3. 他们不想支持甚至可以选择使用非重叠管道的代码。

有了这样的推理和态度,恐怕我不能想到任何方式来改变补丁,以适应他们的要求...他们似乎决心禁止不重叠的管道从未被使用。我已经使用补丁一段时间了,而没有任何问题。此外,我不能想到任何情况下, pipe_nooverlap 标志将打破(看到我的后续电子邮件在他们的邮件列表),但我把它作为一个

With reasoning and attitudes like this, I'm afraid I can't think of any way to change the patch to suit their requirements... they seem determined to forbid non-overlapped pipes from ever being used. I have been using the patch for awhile now, and have not had any problems with it. Also, I can't think of any situations that the pipe_nooverlap flag will break (see my follow-up e-mail on their mailing list), but I left it as a flag just in case there is trouble.

因此,如果要从Cygwin调用非Cygwin Win32或.NET Framework程序,则需要执行以下操作:

So, if you want to call non-Cygwin Win32 or .NET Framework programs from Cygwin, you need to do the following:


  1. 将补丁应用到您使用的任何Cygwin版本的源代码。

  2. 设置 pipe_byte pipe_nooverlap code>环境变量中的标志

  1. Apply my patch to the source of whatever Cygwin version you are using. Do not expect this patch to show up in future Cygwin versions.
  2. Set the pipe_byte and pipe_nooverlap flags in the CYGWIN environment variable.

... 目前!!!

This works... for now!!! I post this in case it helps anyone else who still wants to use Cygwin for some things.

推荐答案

我发现的最好的替代方案是 Gow(Windows上的Gnu)

The best alternative I found is Gow (Gnu On Windows).

它是Cygwin的轻量级替代品,约轻10倍。
据我所知,使用Gow安装的130个工具是常规的Win32应用程序。

It's a lightweight alternative to Cygwin, about 10 times lighter. As far as I know the 130 tools installed with Gow are regular Win32 applications.

这篇关于Cygwin的替代方案? - Cygwin不支持本地支持Win32应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆