Exiting, quitting, or halting refers to the termination of a process or program.
Questions tagged [exit]
2585 questions
31
votes
2 answers
python sys.exit not working in try
Python 2.7.5 (default, Feb 26 2014, 13:43:17)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> try:
... sys.exit()
... except:
... print "in except"
...
in…

onlyvinish
- 435
- 1
- 5
- 20
31
votes
3 answers
in zsh, how do I do a conditional on the exit status of a program?
I want to do something like:
if [[ git status &> /dev/null ]]; then
echo "is a git repo";
else
echo "is not a git repo";
fi
except I don't know how to check the exit status. How do I fix this?

anon
- 41,035
- 53
- 197
- 293
29
votes
9 answers
What can cause Java to keep running after System.exit()?
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…

uckelman
- 25,298
- 8
- 64
- 82
29
votes
1 answer
what does a python process return code -9 mean?
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,…

guettli
- 25,042
- 81
- 346
- 663
27
votes
4 answers
When abort() is preferred over exit()?
I know the differences between the two. One notable thing is that abort() sends SIGABRT signal, so it may be relevant when your software relies on them. But for a typical application exit() seems to be more safe version of abort()...? Are there any…

mip
- 8,355
- 6
- 53
- 72
26
votes
3 answers
Close multiple goroutine if an error occurs in one in go
consider this function :
func doAllWork() error {
var wg sync.WaitGroup
for i := 0; i < 2; i++ {
wg.add(1)
go func() {
defer wg.Done()
for j := 0; j < 10; j++ {
result, err :=…

felix
- 9,007
- 7
- 41
- 62
26
votes
7 answers
Elegant way for exiting a function neatly without using goto in C
We often write some functions which have more than one exit point (that is, return in C). At the same time, when exiting the function, for some general works such as resource cleanup, we wish to implement them only once, rather than implementing…

ACcreator
- 1,362
- 1
- 12
- 29
26
votes
5 answers
How to use Application.Exit Event in WPF?
I need to delete some certain files, then user closes program in WPF. So I tried MDSN code from here http://msdn.microsoft.com/en-us/library/system.windows.application.exit.aspx this way:
this code located here App.xml.cs
public partial class App :…

Rocketq
- 5,423
- 23
- 75
- 126
26
votes
5 answers
How to exit from find -exec if it fails on one of the files
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?

FORTRAN
- 567
- 1
- 6
- 13
26
votes
1 answer
Prompt on exit in PyQt application
Is there any way to promt user to exit the gui-program written in Python?
Something like "Are you sure you want to exit the program?"
I'm using PyQt.

Kirill Titov
- 2,060
- 5
- 21
- 33
25
votes
4 answers
How can I immediately close a program in C?
I am writing C code, in which I am analyzing some data. I have set the program to handle only 100 data inputs. When it has more than 100 inputs, it is giving a segmentation fault. I want to create a way so that when the number of inputs is above 100…

Syntax_Error
- 5,964
- 15
- 53
- 73
25
votes
12 answers
Exit/Finish an app/activity - android
I've got 4 activities say Act1, Act2, Act3 and Act4.
A button in Act1 opens Act2, a button in Act2 opens Act3, a button in Act3 opens Act4.
I want two things to be done:
I've a button in Act4 which directs the user to Act1, the prob is when the…

kumareloaded
- 3,882
- 14
- 41
- 58
24
votes
2 answers
Android: How can I detect if the Back button will exit the app (i.e. this is the last activity left on the stack)?
I'd like to warn the user if the back press is going to finish the last activity on the stack, thereby exiting the app. I'd like to pop up a little toast and detect a 2nd back press within the next few seconds and only then call finish().
I already…

Artem Russakovskii
- 21,516
- 18
- 92
- 115
23
votes
3 answers
Will exit() or an exception prevent an end-of-scope destructor from being called?
Let's say I have the following code:
struct mytype
{
~mytype() { /* do something like call Mix_CloseAudio etc */ }
};
int main()
{
mytype instant;
init_stuff();
start();
return 0;
}
Is that destructor guaranteed to be called…

Truncheon
- 916
- 2
- 12
- 25
22
votes
8 answers
Ctrl-C for quitting Python in Powershell now not working
Python fails to quit when using Ctrl-C in Powershell/Command Prompt, and instead gives out a "KeyboardInterrupt" string.
Recently I've reinstalled Windows 10. Before the reinstall Ctrl-C quit python (3.5/2.7) fine, with no output.
Does anyone know…

oblong
- 625
- 2
- 6
- 8