exit

Any benefit in using WEXITSTATUS macro in C over division by 256 on exit() status?

为君一笑 提交于 2019-12-17 10:54:51
问题 I was doing an exercise for university where I had to return a value with exit, that value was actually a count of something. This could be above 255 (which exit() can't handle) but the teacher suggested to use test data where the count could never go above that value. After all this, I needed to handle this count value, the exit status, I got this value in the main process by using waitpid(). To my surprise, if the child process returned 1, the "real" value in the main process was 256, 2 was

Exit batch script from inside a function

泪湿孤枕 提交于 2019-12-17 10:42:29
问题 I have a problem with my batch file. It builds several programs automatically by doing something like this: set some compilation flags run 'gmake all' call the "check error level" function and if errorlevel 1, exit So it looks like this: set FLAG=1 ... gmake all call :interactive_check set OTHERFLAG=1 ... gmake all call :interactive_check There's 6 or 7 of these (and it might grow). So I made a function to check errorlevel instead of copy/pasting it at every step. The problem is this: the

Under what circumstances are C++ destructors not going to be called?

狂风中的少年 提交于 2019-12-17 10:22:31
问题 I know that my destructors are called on normal unwind of stack and when exceptions are thrown, but not when exit() is called. Are there any other cases where my destructors are not going to get called? What about signals such as SIGINT or SIGSEGV? I presume that for SIGSEGV, they are not called, but for SIGNINT they are, how do I know which signals will unwind the stack? Are there any other circumstances where they will not be called? 回答1: Are there any other circumstances where they

What does sys.exit really do with multiple threads?

谁都会走 提交于 2019-12-17 07:47:55
问题 I was really confused by sys.exit() in python. In python documentation, it says "Exit from Python"; does that mean when sys.exit() is called in a python program, the process will exit? If so, the code below shows a different result: import sys import time import threading def threadrun(): while(True): time.sleep(1) if __name__=="__main__": t=threading.Thread(target=threadrun) t.start() sys.exit() Launching this program in linux, result was not the expected one as python documentation says but

Close multiple goroutine if an error occurs in one in go

本秂侑毒 提交于 2019-12-17 07:39:36
问题 consider this function : func doAllWork() error { var wg sync.WaitGroup wg.Add(3) for i := 0; i < 2; i++ { go func() { defer wg.Done() for j := 0; j < 10; j++ { result, err := work(j) if err != nil { // can't use `return err` here // what sould I put instead ? os.Exit(0) } } }() } wg.Wait() return nil } In each goroutine, the function work() is called 10 times. If one call to work() returns an error in any of the running goroutines, I want all the goroutines to stop immediately, and the

exit application when click button - iOS [duplicate]

巧了我就是萌 提交于 2019-12-17 07:39:33
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: Exit application in iOS 4.0 I have a AlertView which displays some text and an "OK" button. Is there any way to exit application when clicked on OK button? 回答1: exit(X) , where X is a number (according to the doc) should work. But it is not recommended by Apple and won't be accepted by the AppStore. Why? Because of these guidelines (one of my app got rejected): We found that your app includes a UI control for

Python subprocess: callback when cmd exits

杀马特。学长 韩版系。学妹 提交于 2019-12-17 06:27:30
问题 I'm currently launching a programme using subprocess.Popen(cmd, shell=TRUE) I'm fairly new to Python, but it 'feels' like there ought to be some api that lets me do something similar to: subprocess.Popen(cmd, shell=TRUE, postexec_fn=function_to_call_on_exit) I am doing this so that function_to_call_on_exit can do something based on knowing that the cmd has exited (for example keeping count of the number of external processes currently running) I assume that I could fairly trivially wrap

Difference between return and exit in Bash functions

天大地大妈咪最大 提交于 2019-12-17 04:38:32
问题 What is the difference between the return and exit statement in Bash functions with respect to exit codes? 回答1: From man bash on return [n] ; Causes a function to stop executing and return the value specified by n to its caller. If n is omitted, the return status is that of the last command executed in the function body. ... on exit [n] : Cause the shell to exit with a status of n. If n is omitted, the exit status is that of the last command executed. A trap on EXIT is executed before the

SQL Server - stop or break execution of a SQL script

我们两清 提交于 2019-12-17 02:52:38
问题 Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command? I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or lookups fail. 回答1: The raiserror method raiserror('Oh no a fatal error', 20, -1) with log This will terminate the connection, thereby stopping the rest of the script from running. Note that both severity level 20 or higher and the WITH LOG option are

different output with exit() and _exit()?

﹥>﹥吖頭↗ 提交于 2019-12-14 03:37:06
问题 why it showing different output???can anyone explain me in depth. 1. #include <stdlib.h> #include <stdio.h> int main (void) { printf ("Using exit ... \ n"); printf ("This is the content in buffer"); exit (0); } Output: Using exit ... This is the content in buffer 2. # Include <unistd.h> # Include <stdio.h> int main (void) { printf ("Using exit ... \ n"); printf ("This is the content in buffer"); _exit (0); } Only output: Using exit ... 回答1: If we read _exit() 's documentation, we note: Causes