当JVM退出时,我收到以下消息:
JVM process exited with a code of 10
Run Code Online (Sandbox Code Playgroud)
退出代码10是什么意思?
我想知道什么,当背景失败时,黄瓜会返回退出代码0(据我所知,这意味着"确定").
现在失败的步骤可能不应该在背景中(最好在'之前'钩子我想 - ).但有人知道它退回此退出代码的理念是什么?这是一个错误还是一个功能?
附录:一个更具体的例子:让我们说这段代码通过:
Feature: Figuring out how Cucumber works
As a developer
I want to find out why cuccies fail, but my build doesnt
In order to have more confidence in my build
Background: logging in into the system
Given I am logged in
Scenario: creating a new test set
When I do something
Then I should see "you've done something"
Run Code Online (Sandbox Code Playgroud)
它返回退出代码0.让它失败:
Background: logging in into the system
Given I am logged in
Scenario: creating a new test …Run Code Online (Sandbox Code Playgroud) 如何在使用时检测到控制台关闭时触发功能Environment.Exit(0)?
这是关于在POSIX(Linux)环境中运行的应用程序.处理大多数信号(例如Ctrl+ C- 信号2,SIGINT)和其他信号.完成后,exit()系统调用将从处理程序中调用,并带有所需的退出代码.
但是,有些信号如Signal 9和Signal 15无法处理.
不幸的是,如果信号9或15是终止的原因,启动给定应用程序的父进程(外部脚本)需要知道并清理一些东西.
是否有预定义的退出代码可以由父进程接收以了解上述内容?
启动应用程序的脚本是bash_script.应用程序本身在C.
python中的这段脚本:
cmd = 'installer.exe --install ...' #this works fine, the ... just represent many arguments
process = subprocess.Popen(cmd)
process.wait()
print(process.returncode)
Run Code Online (Sandbox Code Playgroud)
这段代码在我看来运作正常,问题在于价值.returncode.
installer.exe没问题,做了很多测试,现在我尝试在python中创建一个脚本,以便在执行此installer.exe的许多天内自动执行测试.
installer.exe返回: - 成功为0; - 失败和错误是负数
我有一个特定的错误,即installer.exe返回-307.但是python在执行print(process.returncode)它时会显示4294966989 ...我如何在python中处理负数,在这种情况下显示-307?
我是python的新手,env是win7 32和python 3.4.
编辑:最终的代码工作 此代码的部分是运行许多简单的测试:
import subprocess, ctypes, datetime, time
nIndex = 0
while 1==1:
cmd = 'installer.exe --reinstall -n "THING NAME"'
process = subprocess.Popen( cmd, stdout=subprocess.PIPE )
now = datetime.datetime.now()
ret = ctypes.c_int32( process.wait() ).value
nIndex = nIndex + 1
output = str( now ) + …Run Code Online (Sandbox Code Playgroud) 我希望我的Ruby脚本在某个条件下返回任何非零退出状态.退出状态本身并不重要,只要它不为零即可.我测试了它是如何完成的:
test_exit.rb:
exit 4
Run Code Online (Sandbox Code Playgroud)
test_exit_wrap.rb:
system("ruby test_exit.rb")
puts $?.exitstatus
Run Code Online (Sandbox Code Playgroud)
CMD:
> ruby test_exit_wrap.rb
4
Run Code Online (Sandbox Code Playgroud)
这太棒了,因为它正是我想要的.然后我试着在我的项目中复制它.
pullrequest.rb:
results = [install_result.class, clicks_result.class, event_result.class, tuples_result.class, match_result.class]
if results.include? NilClass
puts "result included nil"
exit 4
end
Run Code Online (Sandbox Code Playgroud)
rakefile.rb:
command = "irb #{@script} #{@app_id} #{start_date} #{end_date} #{start_time} #{end_time} #{@timezone} #{@database}"
system("#{command}")
puts $?.exitstatus
if $?.exitstatus != 0
puts "!!!!!!!!!!!!!!!!!!!!!! FAILED JOB !!!!!!!!!!!!!!!!!!!!!!!!!!"
@backjob_queue << fail
end
Run Code Online (Sandbox Code Playgroud)
CMD:
pullkochava.rb(main):032:1>
result included nil
=> nil
pullrequest.rb(main):032:0>
0
Run Code Online (Sandbox Code Playgroud)
(当然,剪掉这些,希望它仍然有意义;同样@script等于pullrequest.rb,我已经双重检查了)我们可以看到if results.include?块肯定会被执行,但是出口4似乎丢失了.0来自puts $ ?. exitstatus,我永远不会让它返回任何东西而不是0.我已经尝试过引发错误,不同的退出代码和中止.Abort确实返回非零退出代码; 然而它也中止了耙子.它将放置FAILED JOB,但是rakefile无法将@backjob_queue保存到我的数据库中.
我错过了什么吗?如何返回不会中止rake的非零退出状态?
我正在尝试在 rundeck 中运行一个运行“puppet agent -tod”的任务,但是由于 puppet 返回的退出代码为 2,这意味着它应用了一些更改,如https://docs.puppetlabs.com/references /3.4.2/man/agent.html在 --detailed- exitcodes部分,但 rundeck 与 0 不同的所有标记为失败。我可以以某种方式强制显示 0 退出代码而不是 2 吗?
谢谢你们!
此代码导致 IllegalThreadStateException 运行时错误来自 if 语句:
public static void main(String args[]) throws IOException, InterruptedException {
Runtime runtime = Runtime.getRuntime();
Process proc = new ProcessBuilder("\"c:\\[directory]/doer.exe\"").start();
if(proc.exitValue() == 1)
System.out.println("Output: 1");
}
Run Code Online (Sandbox Code Playgroud)
应该专门运行的可执行文件具有退出代码 1。我做错了什么,我该如何解决?
我有一个简单的c ++程序,它引发了SIGSEGV:
#include <iostream>
#include <signal.h>
int main() {
std::cout << "Raising seg fault..." << std::endl;
raise(SIGSEGV);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
运行此程序时,我得到以下输出
Raising seg fault...
Segmentation fault
Run Code Online (Sandbox Code Playgroud)
但是当我使用管道在perl脚本中运行我的程序时,分段错误消失了.这是我的Perl脚本:
use strict;
use warnings;
my $cmd ="./test";
open (OUTPUT, "$cmd 2>&1 |") || die();
while (<OUTPUT>) {
print;
}
close (OUTPUT);
my $exit_status = $?>>8;
print "exit status: $exit_status\n";
Run Code Online (Sandbox Code Playgroud)
运行脚本时,我得到以下输出:
Raising seg fault...
exit status: 0
Run Code Online (Sandbox Code Playgroud)
怎么可能这样呢?分段错误在哪里?为什么退出状态为0?
C和C ++允许我们从中返回退出代码main。为什么Haskell不这样做?在我看来,这很简单;只是要求main :: IO Int而不是IO t。
我意识到以下内容不会像C程序员所期望的那样:
main :: IO Int
main = do
return 1 -- Execution continues, thanks to (>>)
putStrLn "Unreachable?"
return 2 -- Exit code 2?
Run Code Online (Sandbox Code Playgroud)
这种退出代码执行起来可能很棘手,但实际上有多么棘手?对我来说,似乎比必须导入好System.Exit。