exit

Exit functions in C

安稳与你 提交于 2019-12-04 03:08:59
问题 What is the difference between exit() , _exit() and _Exit() in C? How do I decide which to use? On bash, man 2 exit gave me the page _EXIT(2), whereas man 3 exit gave the page EXIT(3). 回答1: exit() terminating after cleanup. _exit() terminating immediately after call. If you have some stack corrupted while exit() function was called program may close with Segmentation Fault, if you are use _exit() , program exit in quick mode. From http://msdn.microsoft.com/en-us/library/6wdz5232.aspx you have

How to exit from find -exec if it fails on one of the files

丶灬走出姿态 提交于 2019-12-04 02:54:31
问题 I want to run the command find some/path -exec program \{} \; but I want the find command to quit as soon as the command program \{} fails on any of the files found. Is there a simple way of doing this? 回答1: I think it is not possible to achieve what you want, only with find -exec . The closest alternative would be to do pipe find to xargs , like this: find some/path -print0 | xargs -0 program or find some/path -print0 | xargs -0L1 program This will quit if program terminates with a non-zero

does exit() free allocated memory on both _SUCCESS and _FAILURE

笑着哭i 提交于 2019-12-04 02:21:39
This a short snippet of code, with two calls to exit(3) in case of failure. Do these calls deallocate memory allocated by malloc? Google search once says it does, and even more times, it doesn't... Should I add free()? Also: which is better if (!word) (it would also work for eg. word == 0 which is different from word == NULL, so I guess it is wrong) or if (word == NULL) ? char *word = NULL, *temp = NULL; word = (char *)malloc(sizeof(char) * size); if (!word) { /* or maybe rather it should be (word == NULL) */ perror("malloc fail"); if (fclose(fp)) { perror("fclose fail"); exit(3); /* exit

java swing close window without exiting app

末鹿安然 提交于 2019-12-04 01:01:38
问题 I have a little frame where I ask user & password. This frame will be opened clicking over a button in a main window. Then I have two buttons: ok and cancel. When I click on "cancel" button, I need to close this frame without exiting the app. How can I do that? 回答1: You can use either Frame.hide() or Frame.dispose(). I would also recommend to look into JDialog or JOptionPane Correction: hide() is deprecated. SetVisible(false) should be used instead 回答2: Maybe a cleaner way is just change the

what does a python process return code -9 mean?

半城伤御伤魂 提交于 2019-12-03 20:46:18
问题 I have a python script which returns the exit status of -9. I tried to get the root of the problem with the atexit module, but it does not get called. Any hints to help me find why and where my script terminates? The problem is reproducible, operating system: linux 3.7.10 回答1: The script was killed by the operating system. Negative return values are the signal number which was used to kill the process. The script needed too much memory. I found this in syslog: Out of memory: Kill process

VB 6 crash on exit

六眼飞鱼酱① 提交于 2019-12-03 20:11:46
I have a legacy vb6 app that crashes on exit - both as an executable and in the IDE. How can I avoid the crash? I am currently unloading the forms (except the frmmain) in form_unload , releasing all the ADODB RecordSets, setting all the boundcollections = nothing. I have attempted to SetErrorMode SEM_NOGPFAULTERRORBOX in the form_terminate event and that has not stopped the error from occurring. I have also checked for subclasses being instantiated in my code and found none. I have checked into the components from outside Microsoft that are used - they are the ComponentOne flexgrid 8 spelling

Where to “quit” with looper?

大城市里の小女人 提交于 2019-12-03 17:09:46
I have a problem with a looper. I call looper.prepare() , and after doing something it all works fine. But if I rotate the device I get an exception on the prepare. 07-12 16:40:09.760: E/activity(15809): java.lang.RuntimeException: Only one Looper may be created per thread I'm trying to quit the looper, but it doesn't do anything. Here is my AsyncTask: @Override protected String doInBackground(String... args) { try{Looper.prepare(); //here start the exception try { URL url = new URL(link); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.connect();

Is it well-defined behaviour to exit the program before main?

。_饼干妹妹 提交于 2019-12-03 12:32:14
It's definitely possible to execute code before main is called, as seen by many examples in this question . However, what if in that pre-main code, the program is told to exit via std::exit or std::abort ? Since main is defined as the start of a program, what consequences are there from exiting before the start? Upon printing something in each section, I get the following results: Format: Section : output Main : main Init (called before main) : init Exit (set up with std::atexit inside Init) : exiting Sample runs: Init called without exiting: init main returns 0 Init calls std::exit(0): init

Why is this Bash function within a git alias executing twice, and why does adding `exit` fix it?

醉酒当歌 提交于 2019-12-03 12:31:26
If I fail to explicitly call exit for certain function-based Bash scripts then there are additional unexpected executions for some functions. What is causing this? The behavior was first noticed while making a git alias as part of answering another user's question on StackOverflow . That alias was composed of this script ( which runs the function twice instead of once ): #!/usr/bin/env bash github(){ echo github; }; twitter(){ echo twitter; }; facebook(){ echo facebook; }; if [[ $(type -t "$1") == "function" ]]; then "$1"; else echo "There is no defined function for $1"; fi; But this slightly

How do I get the Tor exit node IP address over the control port?

余生长醉 提交于 2019-12-03 11:40:46
问题 I want to monitor the status of running Tor instances. I am already able to get information via a TCP connection to the control ports. E.g. "GETINFO stream-status" returns data, but I am not able to determine the IP address of the currently chosen exit node. It would be possible to simply request something like whatismyip.org, but that is too slow and does not scale well. So what is the best way to get the exit node IP address of a Tor connection? 回答1: This is a great question! Here's a short