exit

what does a python process return code -9 mean?

半世苍凉 提交于 2019-11-30 19:09:07
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 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 26184 (python) score 439 or sacrifice child Killed process 26184 (python) total-vm:628772kB, anon-rss:447660kB,

Can exit() fail to terminate process?

三世轮回 提交于 2019-11-30 14:53:33
问题 I have a registered a signal handler in my program. Upon receiving an undesired signal (SIGABRT), i call 'exit(-1)' in signal handler to exit the process. But as noticed on few ocassions, it calls exit() but fails to terminate the process. The issue was randomly generated and I strongly suspect on execution of exit(). Can there be any reasons or cases in which the exit() can fail to terminate the process. Thanks. 回答1: Are you calling exit() from the signal handler? In man 7 signal , section

React Native: Double back press to Exit App

对着背影说爱祢 提交于 2019-11-30 14:19:10
How to exit application with twice clicking the back button without needing Redux I was looking for a solution to limit the user and do not get out of the application with one click in react native. Mahdi Bashirpour import React, {Component} from 'react'; import {BackHandler, View, Dimensions, Animated, TouchableOpacity, Text} from 'react-native'; let {width, height} = Dimensions.get('window'); export default class App extends Component<Props> { state = { backClickCount: 0 }; constructor(props) { super(props); this.springValue = new Animated.Value(100); } componentWillMount() { BackHandler

Can exit() fail to terminate process?

寵の児 提交于 2019-11-30 12:58:34
I have a registered a signal handler in my program. Upon receiving an undesired signal (SIGABRT), i call 'exit(-1)' in signal handler to exit the process. But as noticed on few ocassions, it calls exit() but fails to terminate the process. The issue was randomly generated and I strongly suspect on execution of exit(). Can there be any reasons or cases in which the exit() can fail to terminate the process. Thanks. Are you calling exit() from the signal handler? In man 7 signal , section Async-signal-safe functions you can see all the functions that are guaranteed to work when called from an

Is there a method that tells my program to quit?

对着背影说爱祢 提交于 2019-11-30 11:47:21
问题 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, can you think of another solution? 回答1: One way is to do: sys.exit(0) You will have to import sys of course. Another way is to break out of your infinite loop. For example, you could do this: while True: choice = get_input() if choice == "a": # do

Prompt on exit in PyQt application

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 11:05:28
问题 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. 回答1: Yes. You need to override the default close behaviour of the QWidget representing your application so that it doesn't immediately accept the event. The basic structure you want is something like this: def closeEvent(self, event): quit_msg = "Are you sure you want to exit the program?" reply = QtGui.QMessageBox.question(self, 'Message', quit

Closing Application with Exit button [duplicate]

天涯浪子 提交于 2019-11-30 10:12:33
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: android - exit application code 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? 回答1: Below used main.xml file <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android

How to save the state of an Android CheckBox when the users exits the application?

若如初见. 提交于 2019-11-30 06:39:41
问题 Is there any way by which I can save the state of my checkboxes (checked or unchecked) when user exits the application so that I can reload this state when the application restarts? @Override public void onPause() { super.onPause(); save(itemChecked); } @Override public void onResume() { super.onResume(); checkOld = load(); for (int i = 0 ; i < checkOld.length; i++) { notes.ctv.get(i).setChecked(checkOld[i]); } } @Override public void onRestart() { super.onResume(); checkOld = load(); for

How to run one last function before getting killed in Python?

天涯浪子 提交于 2019-11-30 06:35:31
Is there any way to run one last command before a running Python script is stopped by being killed by some other script, keyboard interrupt etc. import time try: time.sleep(10) finally: print "clean up" clean up Traceback (most recent call last): File "<stdin>", line 2, in <module> KeyboardInterrupt If you need to catch other OS level interrupts, look at the signal module: http://docs.python.org/library/signal.html Signal Example from signal import * import sys, time def clean(*args): print "clean me" sys.exit(0) for sig in (SIGABRT, SIGBREAK, SIGILL, SIGINT, SIGSEGV, SIGTERM): signal(sig,

How to gracefully shutdown a Java application that is terminated as a result of closing the command line from which it was executed?

拥有回忆 提交于 2019-11-30 05:34:04
问题 There is a an answered question on Best Way to Gracefully Shutdown a Java Command Line Program. A shutdown hook does the job in case when a program was terminated by Ctrl+C. My question is how to gracefully exit if the command line itself is closed during the execution of a Java program? I tested with shutdown hook but it didn't work in this case. I cannot find out what happens to the virtual machine in this scenario. Is the process and all its threads killed instantly? What kind of signal