4 ms·
Sure you can: 1. Create an empty file when the application launches 2. When the application terminates, write the reason for termination into the file. 3. Wh
by Skunkleton 8y ago
Sure you can:
1. Create an empty file when the application launches
2. When the application terminates, write the reason for termination into the file.
3. When the app launches again, read the file. If it was empty, then you were SIGKILL'd, or you crashed.
- Buttons840 8y agoA kill -9 wouldn't give you a chance to write the reason for termination to a file. It's the equivalent of the OS saying "you have already run your last CPU cycle, you will receive zero more CPU cycles, good bye". You might be able to write the word "bad" in a file, and then clear the file if your app closes nicely. If you start and find the word "bad" in the file, then you know you were killed. A slight variation of what you suggested.
- slededit 8y agoWhich is why the absence of a reason in the file is indication it was killed.
- Buttons840 8y agoYou're right.
- jacobsenscott 8y agoThat's what the empty file tells you.
- masklinn 8y ago> you were SIGKILL'd, or you crashed. "Might have been killed, might have crashed" is not helpful, and the inability to know is the very issue at hand here. You can't know whether your application crashed, the user forcefully killed it or you fell afoul a background killer. What now, do you start spamming the user anyway?
- Skunkleton 8y agoMost of the time when you crash there is a signal associated with that which can be handled. If you application terminated normally under an error case, then that has to be captured through the same mechanism.
- charleslmunger 8y agoAndroid doesn't offer any signal of normal termination. Your process gets killed when the OS needs memory for some other app.