What is the difference between exit and abort?

“Exit, Exit! Abort, Raise…Get Me Outta Here!” describes everything you’d want to know I think. In short: Kernel.exit(code) “exits” the script immediately and returns the code to the OS, however, just before doing it, it calls any registered at_exit handler that your code could have registered. Kernel.exit!(code) does the same, but exits immediatelly, no at_exit … Read more

How to exit when back button is pressed?

In my Home Activity I override the “onBackPressed” to: @Override public void onBackPressed() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } so if the user is in the home activity and press back, he goes to the home screen. I took the code from Going to home screen Programmatically

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

Are there any other circumstances where they[destructors] will not be called? Long jumps: these interfere with the natural stack unwinding process and often lead to undefined behavior in C++. Premature exits (you already pointed these out, though it’s worth noting that throwing while already stack unwinding as a result of an exception being thrown leads … Read more

Closing Application with Exit button [duplicate]

Below used main.xml file <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:id=”@+id/txt1″ android:text=”txt1″ /> <TextView android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:id=”@+id/txt2″ android:text=”txt2″/> <Button android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:id=”@+id/btn1″ android:text=”Close App” /> </LinearLayout> and text.java file is below import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class testprj extends Activity { /** Called when … Read more

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

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_code exit $ret_code fi } command=”ls -l | grep p” safeRunCommand “$command” Now if you look into this code, the few things that I … Read more

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

Option #1: Simply never catch exceptions. Exceptions don’t have much overhead when they’re not thrown or caught; if you’re throwing and not prepared to catch, well, you’re doing to die anyway, so the performance impact at that point is trivial. Note also that stack unwinding will not be performed if an exception is not handled; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)