exit

Is there a replacement for EXIT_SUCCESS and EXIT_FAILURE in Java?

怎甘沉沦 提交于 2019-12-03 11:01:52
In a C program, I generally use EXIT_SUCCESS or EXIT_FAILURE in exit() function to improve clarity and understandability of the program. But in System.exit() I couldn't use these MACROS. I can define my own interface as public interface ReturnValues { public int EXIT_SUCCESS = 0; public int EXIT_FAILURE = 1; } Other than my own implementation, is there any other way in java to use these Macros? (like using predefined library class variables or by implementing predefined interface etc..) No, there is no predefined constants in Java for SUCCESS and FAILURE. Certainly because there might be

What can cause Java to keep running after System.exit()?

≯℡__Kan透↙ 提交于 2019-12-03 09:52:43
I have a Java program which is being started via ProcessBuilder from another Java program. System.exit(0) is called from the child program, but for some of our users (on Windows) the java.exe process associated with the child doesn't terminate. The child program has no shutdown hooks, nor does it have a SecurityManager which might stop System.exit() from terminating the VM. I can't reproduce the problem myself on Linux or Windows Vista. So far, the only reports of the problem come from two Windows XP users and one Vista user, using two different JREs (1.6.0_15 and 1.6.0_18), but they're able

Exit with error code in go?

孤者浪人 提交于 2019-12-03 08:08:39
问题 What's the idiomatic way to exit a program with some error code? The documentation for Exit says "The program terminates immediately; deferred functions are not run.", and log.Fatal just calls Exit . For things that aren't heinous errors, terminating the program without running deferred functions seems extreme. Am I supposed to pass around some state that indicate that there's been an error, and then call Exit(1) at some point where I know that I can exit safely, with all deferred functions

Windows exit

时光怂恿深爱的人放手 提交于 2019-12-03 08:06:48
退出 CMD.EXE 程序(命令解释器)或当前批处理脚本。 EXIT [/B] [exitCode] /B 指定要退出当前批处理脚本而不是 CMD.EXE。如果从一个 批处理脚本外执行,则会退出 CMD.EXE exitCode 指定一个数字号码。如果指定了 /B,将 ERRORLEVEL 设成那个数字。如果退出 CMD.EXE,则用那个数字设置 过程退出代码。 来源: https://www.cnblogs.com/YZFHKMS-X/p/11784454.html

difference between System.exit(0) and System.exit(-1) [duplicate]

China☆狼群 提交于 2019-12-03 07:54:31
This question already has an answer here: Difference in System. exit(0) , System.exit(-1), System.exit(1 ) in Java 11 answers Can any one share to me difference between System.exit(0) and System.exit(-1) it is helpful if you explain with example. It's just the difference in terms of the exit code of the process. So if anything was going to take action based on the exit code (where 0 is typically success, and non-zero usually indicates an error) you can control what they see. As an example, take this tiny Java program, which uses the number of command line arguments as the exit code: public

How to know the reason why a docker container exits?

牧云@^-^@ 提交于 2019-12-03 06:26:16
问题 I have a Docker container running in a host of 1G RAM (there are also other containers running in the same host). The application in this Docker container will decode some images, which may consume memory a lot. From time to time, this container will exit. I doubt it is due to out of memory but not very sure. I need a method to find the root cause. So is there any way to know what happened for this container's death? 回答1: Others have mentioned docker logs $container_id to view the output of

C++ 杂项

谁说胖子不能爱 提交于 2019-12-03 06:21:28
#include <iostream> #define Main main #define COLOR_GREEN system("color 2"); #include <vector> #include <list> #include <WinSock2.h> #include <WS2tcpip.h> #include <LM.h> #include <winnetwk.h> #include "BitMap.h" #include <wlanapi.h> #include "ATBAudioEngine/ATBAudioEngine.h" #pragma comment(lib,"Ws2_32.lib") #pragma comment(lib,"Mpr.lib") #pragma comment(lib,"netapi32.lib") #pragma comment(lib,"Wlanapi.lib") #include <Windows.h> class disorderly { int m_buf[10] = { 0 }; public: void initBuf() { srand(GetTickCount()); int len = sizeof(m_buf) / sizeof(int); for (int i = 0; i < len; i++) { m_buf

Get exit code for command in bash/ksh

夙愿已清 提交于 2019-12-03 06:12:00
问题 I want to write code like this: command="some command" safeRunCommand $command safeRunCommand() { cmnd=$1 $($cmnd) if [ $? != 0 ]; then printf "Error when executing command: '$command'" exit $ERROR_CODE fi } But this code does not working the way I want. Where I made mistake? 回答1: Below is the fixed code: #!/bin/ksh safeRunCommand() { typeset cmnd="$*" typeset ret_code echo cmnd=$cmnd eval $cmnd ret_code=$? if [ $ret_code != 0 ]; then printf "Error : [%d] when executing command: '$cmnd'" $ret

Run script before Bash exits

爷,独闯天下 提交于 2019-12-03 05:50:55
问题 I'd like to run a script every time I close a Bash session. I use XFCE and Terminal 0.4.5 (Xfce Terminal Emulator), I would like to run a script every time I close a tab in Terminal including the last one (when I close Terminal). Something like .bashrc but running at the end of every session. .bash_logout doesn't work 回答1: You use trap (see man bash ): trap /u1/myuser/on_exit_script.sh EXIT The command can be added to your .profile/.login This works whether you exit the shell normally (e.g.

Java's System.exit(0); vs C++ return 0;

北慕城南 提交于 2019-12-03 05:10:33
When we learn C++ in school, our professor will tell us to write return 0; at the last line of codes in the main function and it is considered as a good programming practice. In Java, I realise some people writes System.exit(0); at the last line of the main method. However, in C++, if I use exit(0); I get penalized by my professor, because (in school) for procedural programming, we are expected to let the program flow till the end of main and let the program stop naturally. My question : Is Java's System.exit(0); similar to C++'s return 0; ? (Or is it similar to C++'s exit(0) ) Is it bad