stdin,stdout和stderr之间是否共享?(stdin, stdout and stderr are shared between?)
我试图了解三个流的行为 -
stdout
,stdin
和stderr
。 我无法从任何教科书中得到答案,所以我来到这里。我知道这三个存储在文件描述符表中,文件描述符为0(stdin),1(stdout)和2(stderr)。 我也知道这些不仅仅是文件描述符,而是可以重定向的I / O流。 好的,分享怎么样?
考虑三种情况:
- 调用fork()时 :子进程和父进程共享文件描述符,但它们是否具有相同的stdin,stdout和stderr?
- 创建线程时:线程共享文件描述符,但是I / O流?
- 调用execl()时 :在这种情况下,当前过程映像将被新过程映像覆盖。 如果我执行
execl("./a.out", "a.out", NULL);
那么这个新的可执行文件是否会获得stdin,stderr和stdout的全新副本?欢迎所有明智的答案。
I am trying to understand the behavior of the three streams -
stdout
,stdin
andstderr
. I couldn't get the answer from any textbook, so I came here.I know that these three are stored in file descriptor table with file descriptors 0 (stdin), 1 (stdout) and 2 (stderr). I am also aware that these are not merely file descriptors but I/O streams which can be redirected. Ok, so how about sharing?
Consider the three cases:
- When a fork() is called : The child process and parent process shares file descriptors, but do they have the same stdin, stdout and stderr ?
- When a thread is created : Threads share file descriptors, but I/O streams?
- When execl() is called : In this case the present process image is overwritten with new process image. If I do
execl("./a.out", "a.out", NULL);
, then will this new executable get a freshcopy of stdin, stderr and stdout?All wise answers are welcome.
原文:https://stackoverflow.com/questions/26687602
最满意答案
请参阅此错误报告 ,特别是密切注释:
这不是一个错误。 理论上,“$ value”可能不是1,2或3,在这种情况下,switch() 不会因其中一个值而离开。 Xdebug不能对“doSomething()”返回的内容做出假设,无法知道所有返回的内容都不是1,2或3.每个函数和方法的最后一个包含一个隐式的“返回NULL”; - 哪个PHP看作可执行代码。 因为存在未命中}的可能代码路径,所以它被标记为“未执行”。
在你的情况下,你有三个案例陈述,我想你已经为它们编写了测试,但是你可能会或可能不会测试第三个隐含的路径 - 如果这三个案例都不匹配怎么办?
tl; dr:为交换机添加一个
default
大小写,并确保你的测试运用它。 或者不要忽略该覆盖线。See this bug report, specifially the close note:
This is not a bug. In theory "$value" could be something else than 1, 2 or 3 and in that case the switch() would not leave due to one of the values. Xdebug can not make assumptions on what "doSomething()" returns an has no way to know that all that ever is returned than 1, 2 or 3. The last } of each function and method includes an implicit "return NULL;" - which PHP sees as executable code. Because there is a possible code path where the } is not hit, it is marked as "not executed".
In your case, you have three case statements, that I imagine you've written tests for, but there's a third, implied path that you may or may not be testing for - what to do if none of the three cases match?
tl;dr: Add a
default
case to the switch, and make sure your tests exercise it. Or don't and ignore that coverage line.
相关问答
更多-
首先:100%的代码覆盖率是一个很好的指标。 这并不总是可以实现的,而且这样做并不总是很重要的:) 问题来自xDebug,告诉PHPUnit这一行是可执行的,但没有涉及。 对于简单的情况,xDebug可以告诉该行不可访问,因此您可以在那里获得100%的代码覆盖率。 看下面的简单例子 。 第二次更新 该问题现在修复了xDebug bugtracker因此构建新版本的xDebug将解决这些问题:) 更新(请参阅下面的有关php 5.3.x的问题) 由于您正在运行PHP 5.4和xDebug的DEV版本,我已经安 ...
-
请注意,这应该是一个评论,并没有回答不直接回答问题。 它质疑问题的有用性。 退出使用emma并开始使用jacoco 。 自2007年左右以来,艾玛一直处于休眠状态。艾玛中心的最新版艾玛插件是从2010年开始的。 截至今日(2013年第一季度)。 从feb-2013 到maven中心有一个版本 。
org.jacoco jacoco 0.6.2.20130 ... -
尝试这个: ASPX <%@page codepage="65001" language="C#" lcid="6153"%> <%@ Import namespace="YourProgram.YourNamespace" %> <% public class MyAuthenticator:IAuthenticator{ public Task
AuthenticateAsync(ICommandRequest commandRequest,CancellationToken ca ... -
导出react redux connect时,流程未覆盖代码警告(Flow uncovered code warning when exporting react redux connect)[2023-06-14]
实际上我也在我的项目中有这个,但我取消选中/取消选择VSCode底部的流覆盖选项。 这将在代码中的流错误和未覆盖的代码之间切换。 未覆盖的代码是外部代码(导入的模块),有时是您自己的,更可能是第三方依赖项(如本例所示),它们不定义流类型。 因此,流程无法检查类型的一致性。 您可以按照注释中的建议从flow-typed安装react-redux类型定义。 实际上我过去曾尝试过这种情况并导致整个世界的痛苦,所以我离开了它。 作为旁注,请考虑这一点......旨在100%类型检查覆盖范围与100%测试覆盖率(谷歌 ... -
请参阅此错误报告 ,特别是密切注释: 这不是一个错误。 理论上,“$ value”可能不是1,2或3,在这种情况下,switch() 不会因其中一个值而离开。 Xdebug不能对“doSomething()”返回的内容做出假设,无法知道所有返回的内容都不是1,2或3.每个函数和方法的最后一个包含一个隐式的“返回NULL”; - 哪个PHP看作可执行代码。 因为存在未命中}的可能代码路径,所以它被标记为“未执行”。 在你的情况下,你有三个案例陈述,我想你已经为它们编写了测试,但是你可能会或可能不会测试第三个隐 ...
-
所以我终于找到了答案,VS格式化选项没有生效的原因是因为ReSharper的格式化选项优先。 该设置位于Resharper - >编辑器 - >编辑器行为“关闭括号上的自动格式”“分号自动格式化”“自动插入右括号” So I finally found the answer, the reason why VS formatting options did not take effect was because the formatting options from ReSharper took prece ...
-
好吧,我现在正坐在角落里,戴上我的帽子。 发现这个: https : //github.com/istanbuljs/nyc/issues/35#issuecomment-121008298 未覆盖线= 17不是未覆盖线的计数,而是仅有一个值的列表,即第17行: total: total || 1, total: total || 1, ,。 修正... test('passing zero forces the default total of 1', () => { const bar = prog ...
-
比赛支架(Tournament bracket)[2023-07-19]
几年前我做过这样的事情。 这是很久以前的事了,我不确定我会以同样的方式做它(它没有真正扩展到双重限制等)你如何输出它可能是一个不同的问题。 我使用了2002 - 2003年的表格。 今天肯定有更好的技术。 锦标赛中的回合数量为log2(玩家)+ 1,只要玩家是您在上面指定的数字之一。 使用此信息,您可以计算出有多少回合。 最后一轮包含最终的赢家。 我存储了这样的播放器信息(调整此内容以获得最佳实践) Tournament Name Size Players Tournament Name ... -
在简单的语句中,两者在Java编程的上下文中是相同的。 我假设method()的返回类型是boolean 。 Java中不允许使用if (method() === false) 。 这是一个编译时错误。 不要在JavaScript语法和Java语法之间混淆。 JSP在内部转换为在服务器上执行的Servlet,并将生成的HTML响应发送回客户端(浏览器)。 所以它根本没有转换为JavaScript 。 In simple statement both are same in the context of Ja ...
-
if [ $(grep -E -f slew_pattern /etc/sysconfig/ntpd) ]; then 对于多个匹配,此命令肯定会失败。 当grep输出在行结束时被分割时,它将抛出一个错误。 grep多个匹配由新行分隔,测试命令变为: [ match1 match2 match3 ... ] 这没有多大意义。 您将获得与grep返回的匹配数不同的错误消息(即test command [的参数数量)。 例如: 2匹配将给你unary operator expected错误 3匹配将给你bi ...