exit-code

Bash & (ampersand) operator

折月煮酒 提交于 2019-11-28 19:37:07
I'm trying to run 3 commands in parallel in bash shell: $ (first command) & (second command) & (third command) & wait The problem with this is that if first command fails, for example, the exit code is 0 (I guess because wait succeeds). The desired behavior is that if one of the commands fails, the exit code will be non-zero (and ideally, the other running commands will be stopped). How could I achieve this? Please note that I want to run the commands in parallel! the best I can think of is: first & p1=$! second & p2=$! ... wait $p1 && wait $p2 && .. or wait $p1 || ( kill $p2 $p3 && exit 1 ) .

How to capture the Return Value of a ScriptBlock invoked with Powershell's Invoke-Command

浪尽此生 提交于 2019-11-28 18:39:00
My question is very similar to this one , except I'm trying to capture the return code of a ScriptBlock using Invoke-Command (so I can't use the -FilePath option). Here's my code: Invoke-Command -computername $server {\\fileserver\script.cmd $args} -ArgumentList $args exit $LASTEXITCODE The problem is that Invoke-Command doesn't capture the return code of script.cmd, so I have no way of knowing if it failed or not. I need to be able to know if script.cmd failed. I tried using a New-PSSession as well (which lets me see script.cmd's return code on the remote server) but I can't find any way to

How to test os.exit scenarios in Go

亡梦爱人 提交于 2019-11-28 17:15:39
Given this code func doomed() { os.Exit(1) } How do I properly test that calling this function will result in an exist using go test ? This needs to occur within a suite of tests, in other words the os.Exit() call cannot impact the other tests and should be trapped. Timo Reimann There's a presentation by Andrew Gerrand (one of the core members of the Go team) where he shows how to do it. Given a function (in main.go ) package main import ( "fmt" "os" ) func Crasher() { fmt.Println("Going down in flames!") os.Exit(1) } here's how you would test it (through main_test.go ): package main import (

Execute bash command in Node.js and get exit code

ぃ、小莉子 提交于 2019-11-28 17:05:12
问题 I can run a bash command in node.js like so: var sys = require('sys') var exec = require('child_process').exec; function puts(error, stdout, stderr) { sys.puts(stdout) } exec("ls -la", function(err, stdout, stderr) { console.log(stdout); }); How do I get the exit code of that command ( ls -la in this example)? I've tried running exec("ls -la", function(err, stdout, stderr) { exec("echo $?", function(err, stdout, stderr) { console.log(stdout); }); }); This somehow always returns 0 regardless

Why does the program return with an exit code other than I specified?

匆匆过客 提交于 2019-11-28 13:49:57
This is a simple program : int main() { return 0; } The exit code is 0 . If I write: int main() { return 700; } The exit code is 188 . Why is 188 instead of 700 the exit code here? cadaniluk While the main function in C returns an int , operating systems don't necessarily use int as the error code . 700 in binary is 1010111100 . Truncating this value to eight bits yields 10111100 . This equals 188 in decimal. That means your OS uses eight bits for error codes. 1 1 Or possibly nine bits because the 8 th bit (we start counting from 0, mind you) is 0 here. This is highly improbably due to 9 not

How do I get the bash command exit code from a Process run from within Java?

爱⌒轻易说出口 提交于 2019-11-28 13:42:21
I have a program which is: import java.io.*; import java.util.*; public class ExecBashCommand { public static void main(String args[]) throws IOException { if (args.length <= 0) { System.err.println("Need command to run"); System.exit(-1); } Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec("./nv0914 < nv0914.challenge"); Process process1 = runtime.exec("echo ${?}"); InputStream is = process1.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; //System.out.printf("Output of running %s is:", Arrays

Is there a complete List of JVM exit codes

独自空忆成欢 提交于 2019-11-28 11:17:46
I am looking for a complete list of all possible jvm exit codes (not java System.exit(x)). The only thing I could find by using a search engine is a list of SIGTERM exit codes: http://journal.thobe.org/2013/02/jvms-and-kill-signals.html . I want to know if there are specific exit codes for uncatched Exceptions? Argument passed to System.exit(x) -> becomes the JVM exit code. Exit code 0 is used to indicate normal exit. Unique positive exit code to indicate specific problem. I want to know if there are specific exit codes for uncatched Exceptions? No. If all non-daemon threads exit normally

Why am I seeing multiple “The thread 0x22c8 has exited with code 259 (0x103).” messages

这一生的挚爱 提交于 2019-11-28 07:54:26
I'm getting a slew of these messages in my Winforms application even though I never explicitly made any threads. Why is this happening? I've looked around for an explanation but it's hard to word an inquiry like this. I'm using Visual Studios 2013 and this is the debug output that I'm concerned about: The thread 0x23a4 has exited with code 259 (0x103). The thread 0x2884 has exited with code 259 (0x103). The thread 0x27ec has exited with code 259 (0x103). The thread 0x1978 has exited with code 259 (0x103). The thread 0x1534 has exited with code 259 (0x103). The thread 0x1ad8 has exited with

seccomp — how to EXIT_SUCCESS?

拜拜、爱过 提交于 2019-11-28 02:51:18
问题 Ηow to EXIT_SUCCESS after strict mode seccomp is set. Is it the correct practice, to call syscall(SYS_exit, EXIT_SUCCESS); at the end of main? #include <stdlib.h> #include <unistd.h> #include <sys/prctl.h> #include <linux/seccomp.h> #include <sys/syscall.h> int main(int argc, char **argv) { prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT); //return EXIT_SUCCESS; // does not work //_exit(EXIT_SUCCESS); // does not work // syscall(__NR_exit, EXIT_SUCCESS); // (EDIT) This works! Is this the ultimate

Process Exit Code When Process is Killed Forcibly

笑着哭i 提交于 2019-11-28 01:54:33
When we kill a process in Windows with Task Manager End Process command, will the process still return an exit code? And if so, what exit code it returns? Thanks In general, a process is terminated using TerminateProcess . The exit code is passed as a parameter to this method. In the case of the task manager, the exit code is set to 1, but I don't know if it's documented anywhere. Yes, it will return non-zero return code which will be wrapped in %ERRORLEVEL% variable. 来源: https://stackoverflow.com/questions/4344923/process-exit-code-when-process-is-killed-forcibly