Questions tagged [exit]

Exiting, quitting, or halting refers to the termination of a process or program.

2585 questions
82
votes
1 answer

Android: Capturing the return of an activity

I have a question regarding launching new activities. It boils down to this. I have 3 tabs on a view A) contains gMap activity B) camera activity C) some random text fields. Requirement is that the application runs in Portrait mode. All 3 tabs…
Chrispix
  • 17,941
  • 20
  • 62
  • 70
77
votes
3 answers

How do you return to a sourced bash script?

I use "source" inside a bash script, as follows: #!/bin/bash source someneatscriptthatendsprematurely.sh I would like to exit from the someneatscriptthatendsprematurely.sh script, without exiting from the main script. Any help appreciated!
codar
  • 7,018
  • 2
  • 18
  • 8
77
votes
2 answers

Is there a way to prevent a SystemExit exception raised from sys.exit() from being caught?

The docs say that calling sys.exit() raises a SystemExit exception which can be caught in outer levels. I have a situation in which I want to definitively and unquestionably exit from inside a test case, however the unittest module catches…
John
  • 14,944
  • 12
  • 57
  • 57
75
votes
6 answers

How to Exit a Method without Exiting the Program?

I am still pretty new to C# and am having a difficult time getting used to it compared to C/CPP. How do you exit a function on C# without exiting the program like this function would? if (textBox1.Text == "" || textBox1.Text == String.Empty ||…
Nightforce2
  • 1,426
  • 5
  • 18
  • 31
73
votes
2 answers

Make R exit with non-zero status code

I am looking for the R equivalent of linux/POSIX exit(n) which will halt the process with exit code n, signaling to a parent process that an error had occurred. Does R have such a facility?
Setjmp
  • 27,279
  • 27
  • 74
  • 92
73
votes
4 answers

What is the difference between using _exit() & exit() in a conventional Linux fork-exec?

I've been trying to figure out how the fork-exec mechanism is used inside Linux. Everything was going on according to the plan until some web pages started to confuse me. It is said that a child process should strictly use _exit() instead of a…
ned1986zha
  • 775
  • 1
  • 6
  • 5
68
votes
5 answers

EXIT_FAILURE vs exit(1)?

What's the difference? Which is preferred, or when should I use each one respectively?
temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
67
votes
9 answers

Python subprocess: callback when cmd exits

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, …
Who
  • 695
  • 1
  • 6
  • 6
66
votes
1 answer

How to run code before program exit?

I have a little console C# program like Class Program { static void main(string args[]) { } } Now I want to do something after main() exit. I tried to write a deconstructor for Class Program, but it never get hit. Does anybody know…
Frank
  • 7,235
  • 9
  • 46
  • 56
60
votes
5 answers

Disabling C++ exceptions, how can I make any std:: throw() immediately terminate?

This C++ program is a CGI script, I have no desire to deal with exceptions. I'd rather get a marginal performance boost and let the OS (Linux) handle cleanup after the process dies. I am using the Standard C++ Library, and want any function to die…
unixman83
  • 9,421
  • 10
  • 68
  • 102
56
votes
5 answers

Get the exit code for a command in Bash and KornShell (ksh)

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…
Kolesar
  • 1,265
  • 3
  • 19
  • 41
50
votes
6 answers

Closing Application with Exit button

I'm a beginner in android, I'm practicing a Project that have a 2 labels and 1 exit button. But when I run this project in android phone the exit button is not working, it won't exit at all. How can I make exit button work?
Thinkerbelle
  • 749
  • 3
  • 9
  • 17
50
votes
12 answers

Bash: One-liner to exit with the opposite status of a grep command?

How can I reduce the following bash script? grep -P "STATUS: (?!Perfect)" recess.txt && exit 1 exit 0 It seems like I should be able to do it with a single command, but I have a total of 3 here. My program should: Read recess.txt Exit 1 (or…
Sean Adkinson
  • 8,425
  • 3
  • 45
  • 64
49
votes
8 answers

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

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?…
WilliamKF
  • 41,123
  • 68
  • 193
  • 295
48
votes
5 answers

Is there a method that tells my program to quit?

For the "q" (quit) option in my program menu, I have the following code: elif choice == "q": print() That worked all right until I put it in an infinite loop, which kept printing blank lines. Is there a method that can quit the program? Else,…
Kudu
  • 6,570
  • 8
  • 27
  • 27