exit-code

Difference between ExitCodeGenerator and System.exit(0)

烂漫一生 提交于 2021-02-10 12:17:06
问题 I recently learned that the proper way to shut down a Spring Boot application is this: public class Application { @Bean public ExitCodeGenerator exitCodeGenerator() { return new ExitCodeGenerator() { @Override public int getExitCode() { return 0; } }; } public static void main(String[] args) throws Exception { System.exit(SpringApplication.exit(SpringApplication.run(Application.class, args))); } } This should return an exit code of 0, or whatever I configure it to return in the getExitCode()

Debugging Inno Setup installer that respawns itself

允我心安 提交于 2021-02-07 10:33:16
问题 As it can be seen from this question we start a new instance of Inno Setup: Instance := ShellExecute(0, '', ExpandConstant('{srcexe}'), Params, '', SW_SHOW); where function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string; lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle; external 'ShellExecuteW@shell32.dll stdcall'; All the code from this question's answer I moved to the VCL_Styles.iss file and included it into my main script. The problem is that after I've

Why does if [ …something… ]; then echo “Exit status is $?” always emit 0?

让人想犯罪 __ 提交于 2021-02-05 09:46:34
问题 What is the correct way to output an exit status in bash? As far as I know, the exit status called by $? corresponds to the status of the last command executed. The script being worked on has a few conditional checks on the files fed as arguments, for example, a check on whether any files were named at all or if a file exists or not. So I have conditional statements like this: if [ $# -eq 0 ] ; then echo "No file name(s) given! \nExit status=$?" exit if [ ! -e "$fName" ] ; then echo "$fName

Bash conditional based on exit code of command

二次信任 提交于 2021-01-29 10:18:21
问题 In Bash, I would like an if statement which is based of the exit code of running a command. For example: #!/bin/bash if [ ./success.sh ]; then echo "First: success!" else echo "First: failure!" fi if [ ./failure.sh ]; then echo "Second: success!" else echo "Second: failure!" fi success.sh #!/bin/bash exit 0 failure.sh #!/bin/bash exit 1 This should print out: First: success! Second: failure! How would I achieve this? Thanks! 回答1: Just remove the brackets: #!/bin/bash if ./success.sh; then

Java process.waitFor() returns with inconsistent value

假装没事ソ 提交于 2021-01-29 05:46:55
问题 Use process = Runtime.getRuntime.exec("other.sh") to lauch other.sh who exits with 1, however, process.waitFor() returns with 0. Under Linux RedHat 7. other.sh just starts another Java process that returns by System.exit(1) . I've seen the same problem in https://coderanch.com/t/326568/java/exitValue-returns-inconsistent-values. However, it said that this was a JDK bug in 1.4 and was fixed already. However, I am using JDK 1.8. I just want to know if there are any other possibilities leading

Return from exit() with fork() is weirdly bitshifted

試著忘記壹切 提交于 2021-01-27 13:40:47
问题 I have a code in C that forks itself sometimes, each fork does something then returns an error code. Currently, each child process returns its ID (0..n). void other(int numero){ ... exit(numero); } int main(...){ for(int i = 0; i < 6; i++){ if(fork() == 0){ other(i); } } int order[6]; for(int i = 0; i < 6; i++){ int code; waitpid(0, &code, 0); order[i] = code; // <-- HERE } } Weirdly, this returns a multiple of the real value. By replacing the line I marked with : order[i] = code >> 8; I

Where to lookup for the meaning “adb screencap” command's exit codes or how to get the meaning programatically?

こ雲淡風輕ζ 提交于 2020-12-15 06:17:26
问题 Process p = Runtime.getRuntime().exec("screencap -p /storage/sdcard0/test3332.png"); p.waitFor(); String error = "error: " + p.exitValue(); p.exitValue() is equal to 11 How to get the "meaning" or message from this exit code? If this should be available in the command's manual, then where to find this manual? Can someone post a link or a reference ? 回答1: The error message can be retrieved in this way: int ch; StringBuilder sb = new StringBuilder(); while((ch = p.getErrorStream().read()) != -1