terminate

Can you track when an android application has been terminated?

别等时光非礼了梦想. 提交于 2019-12-17 16:46:09
问题 Looked at android documentation and it appears that we don't have the ability to know when an app shuts down. Whether it was explicitly by the user or automatically by the operating system. Below is the onTerminate() documentation which is only available in the emulated scenario. public void onTerminate() Since: API Level 1 This method is for use in emulated process environments. It will never be called on a production Android device, where processes are removed by simply killing them; no

Terminate a process tree (C for Windows)

一笑奈何 提交于 2019-12-17 09:50:54
问题 This has been asked before but I can't find a definitive answer, in code. I open a process, ProcessA (with PID 1234). This process opens a child process, ProcessAB (PID 5678). After I'm done I terminate ProcessA but I still have the lingering of ProcessAB. How do I terminate the whole process tree? What I mean, how do I make sure that if I terminate the process I opened I am also terminating all the associated processes? Thanks Code is appreciated. 回答1: Check this thread for grouping

Stop location updates when app terminate

邮差的信 提交于 2019-12-14 01:29:50
问题 I'm developing an app which sends notifications when you are nearby of promoted places. My problem is when I go to background and then I quit the app, I don't want the location services working when the app doesn't work (but I want them to work in background). I saw only 3 apps which close the gps when the app is closed and I want to know how they did that, Facebook, Google Maps and Apple Maps, not Foursquare, not FieldTrips... Thank you everybody. 回答1: you can add an observer for

linux kill process using timeout in milliseconds

笑着哭i 提交于 2019-12-13 21:20:10
问题 I want to force terminate a program after a specified time is elapsed on linux. I found that 'timeout' util in linux can kill a program after a specified time, but it does not accept MILLISECONDS. That is, "timeout TIME ./PROGRAM" kills PROGRAM after TIME elapsed where TIME is not milliseconds but seconds. Is there a way to kill a process after some MILLISECONDS on linux SHELL ? Any comments would be appreciated. 回答1: You can do something like this: #!/bin/bash #execute command in background

Delphi 2006 - What's the best way to gracefully kill a thread and still have the OnTerminate handler fire?

微笑、不失礼 提交于 2019-12-13 13:46:33
问题 I have a thread that sometimes freezes (I suspect) due to a DLL call that never returns. In the general case, where you have calls to blocking routines like Indy, is there a way of recovering from this in such a way that the thread OnTerminate handler fires? Will this happen if I call TerminateThread? 回答1: TerminateThread() is an immediate brute-force termination. It will NOT let the OnTerminaate event fire. The only way OnTerminate can fire is if the thread's Execute() method exits through

how to stop/terminate the step in execution listeners in spring batch?

孤人 提交于 2019-12-13 07:41:16
问题 I had file name validation in step execution listener . If the file name is not valid i want to terminate/stop the step from proceeding into reader . how to achieve this in sprig batch? 回答1: The listener is the wrong place to do data validation. use a processor and throw an appropriate exception if you have to validate single data items. Use a tasklet step prior to a processing step if you want to validate more "general" aspects like the filename or the presence of a file or any other

C++ terminate thread

烈酒焚心 提交于 2019-12-13 01:51:35
问题 I know that this question has been asked and answered many times and I know that the best way to end a thread is to use flags and exit the thread function when it is requested. This is also what I am doing at the moment, but my problem is that the thread function runs for a very Long time, so sometimes I need to wait for several hours until the thread ends. My thread function looks something like this: void threadfunction() { while(!exitRequested) { doSomeWork(); object1.doSomeWork(); object2

PHP shell_exec - how to terminate the process if the connection is closed?

萝らか妹 提交于 2019-12-13 01:16:09
问题 I have a working php script using shell_exec to execute an external program that take about 30 seconds to complete. Problem is that if an user close the browser or the connection is closed for some reason the program executed with shell_exec continue to run for nothing, since it's output can't be sent to the user anymore. Is there a way to kill this process as soon as the connection is closed? Thank you for your help. 回答1: Finally I've solved it! I've used the PHP function connection_aborted(

Cross-platform way to terminate a process in python

末鹿安然 提交于 2019-12-13 00:24:26
问题 When I try to kill a process in windows with the subprocess.Popen.terminate() or kill() commands, I get an access denied error. I really need a cross-platform way to terminate the process if the file no longer exists (Yes, I know it's not the most elegant way of doing what I'm doing), I don't want to have to use platform calls or import win32api if at all possible. Also - Once I kill the task, I should be able to just delete the iteration of that portion of the library, no? (I remember

How to perform an async operation on exit

两盒软妹~` 提交于 2019-12-12 10:29:14
问题 I've been trying to perform an asynchronous operation before my process is terminated. Saying 'terminated' I mean every possibility of termination: ctrl+c Uncaught exception Crashes End of code Anything.. To my knowledge the exit event does that but for synchronous operations. Reading the Nodejs docs i found the beforeExit event is for the async operations BUT : The 'beforeExit' event is not emitted for conditions causing explicit termination, such as calling process.exit() or uncaught