exit

Removing created temp files in unexpected bash exit

筅森魡賤 提交于 2019-12-02 14:07:50
I am creating temporary files from a bash script. I am deleting them at the end of the processing, but since the script is running for quite a long time, if I kill it or simply CTRL-C during the run, the temp files are not deleted. Is there a way I can catch those events and clean-up the files before the execution ends? Also, is there some kind of best practice for the naming and location of those temp files? I'm currently not sure between using: TMP1=`mktemp -p /tmp` TMP2=`mktemp -p /tmp` ... and TMP1=/tmp/`basename $0`1.$$ TMP2=/tmp/`basename $0`2.$$ ... Or maybe is there some better

Java Exit on Windows Shutdown

社会主义新天地 提交于 2019-12-02 12:42:08
问题 I have this code. I want to exit my Java Application if it detects that the computer is shutting down. I have this problem, If shutdown is clicked on windows my java application disconnects from android app connection. I want to display that the java application has been disconnected or it will exit. // Copyright 2012 // Android Remote Desktop Server Ver. 1.0 import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.util.Random; public class ServerWindow

Wait for process to end async and then call a function within the main form

荒凉一梦 提交于 2019-12-02 11:51:38
I'm coding an editor for a game with C#. My programm openes as .txt File by starting a notepad.exe process. If that process exits, I want to call a function within the main form (to update the textbox). Here's what I'm doing so far: void OpenTextEditor(TreeNode node) { Process editor = new Process(); editor.StartInfo.WorkingDirectory = "%WINDIR%"; editor.StartInfo.FileName = "notepad.exe"; var txtfilelocation = GetRealPathByNode(node); var txtfile = File.ReadAllText(txtfilelocation,Encoding.Default); txtfile = txtfile.Replace("\n", "\r\n"); File.WriteAllText(txtfilelocation,txtfile,Encoding

Send App to Background process

余生颓废 提交于 2019-12-02 10:04:01
We do not want to use exit(0) to make the app close, we do however want to allow the app to go to background programmatically and process away, per users allowing this action. Is there a way to send the app to the background programmatically without exit? Simulating the click of the home button? Thank in advance! Not possible. Home button clicks run into the private GSEvents framework. It's exit() or none unfortunately. Is there a way to send the app to the background programmatically without exit? No. The user is supposed to be in control of the app -- the app shouldn't move to the background

Handling Signals in an MPI Application / Gracefully exit

醉酒当歌 提交于 2019-12-02 04:44:33
问题 How can signals be handled safley in and MPI application (for example SIGUSR1 which should tell the application that its runtime has expired and should terminate in the next 10 min.) I have several constraints: Finish all parallel/serial IO first befor quitting the application! In all other circumstances the application can exit without any problem How can this be achieved safely, no deadlocks while trying to exit, and properly leaving the current context jumping back to main() and calling

Will calling System.exit(0); from an object outside of main run garbage collection?

半世苍凉 提交于 2019-12-02 04:32:29
I plan to use an object which is called by my main method to exit the entire program. The object has a method which just runs a System.exit(0). My question is, is this a safe thing to do? If I run System.exit(0) from another object, will garbage collection still clean out the entire program from memory, or will I have issues cleaning the calling class from memory? My thoughts are that either since the JVM will be terminated, the calling class will be garbage-collected, or that I might have issues cleaning the calling class from memory since the object's stack frame is above the main stack

Closing function in a VB.NET console application

筅森魡賤 提交于 2019-12-02 04:26:52
问题 How can I fire off a function when it detects the console closing when using Environment.Exit(0) ? 回答1: The simplest way of doing this is probably to handle the AppDomain.ProcessExit event, which is raised when the application's parent process exits. For example: Module MyApp Sub Main() ' Attach the event handler method AddHandler AppDomain.CurrentDomain.ProcessExit, AddressOf MyApp_ProcessExit ' Do something ' ... Environment.Exit(0) End Sub Private Sub MyApp_ProcessExit(sender As Object, e

Python : Exiting for loop?

可紊 提交于 2019-12-02 04:07:43
问题 I did some research on SO and am aware that many similar questions have been asked but I couldn't quite get my anwser. Anyway, I'm trying to build a library to "encrypt" a string with "Cesar's number" technique wich means I have to take the string and replace each letters with another letter X positions away in the alphabet (I hope that makes sense). Here's my code : from string import ascii_lowercase, ascii_uppercase def creer_encodeur_cesar(distance): retour = lambda x: encodeur_cesar(x,

How can I stop the execution of a Python function from outside of it?

倾然丶 夕夏残阳落幕 提交于 2019-12-02 03:33:09
问题 So I have this library that I use and within one of my functions I call a function from that library, which happens to take a really long time. Now, at the same time I have another thread running where I check for different conditions, what I want is that if a condition is met, I want to cancel the execution of the library function. Right now I'm checking the conditions at the start of the function, but if the conditions happen to change while the library function is running, I don't need its

Java Exit on Windows Shutdown

廉价感情. 提交于 2019-12-02 03:08:47
I have this code. I want to exit my Java Application if it detects that the computer is shutting down. I have this problem, If shutdown is clicked on windows my java application disconnects from android app connection. I want to display that the java application has been disconnected or it will exit. // Copyright 2012 // Android Remote Desktop Server Ver. 1.0 import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.net.*; import java.util.Random; public class ServerWindow implements ActionListener{ private RemoteDataServer server; private Thread sThread; //server thread