If my program does not crash correctly, the system becomes unstable. There really is no workaround. Therefore, if my program crashes and does not reset correctly, then I need to tell the user when he will try to restart it so that the system remains in an unstable state. The correct way to do this is to create a lock file at startup and delete it when it is correctly exit. If I start and this file exists, then I know that I worked before. Is this the right approach?
Two things that may be helpful:
, ? , - , , . , global atom.
// Test if the application has crashed since the last reboot ATOM myAtom = GlobalFindAtom ("MySecretName"); if (myAtom != 0) { // We crashed on last run, inform user and exit // ... exit (0); } // Create a global atom which will be destroyed only on clean termination myAtom = GlobalAddAtom ("MySecretName"); // Run your main program here // ... // Clean termination, delete the atom GlobalDeleteAtom (myAtom);
, , , , . , , o.s.
, , , , , , , , . , . , , .
Microsoft Word (PPT / Excel also) takes a similar approach. A hidden file is created when a document is opened in record mode, and as soon as the application exits from it, it is deleted. The file may contain much more information, such as automatically saving a document every "x" min, etc., But the fact is that your point is valid :-)
Source: https://habr.com/ru/post/1722617/More articles:How the stl vector provides random access - c ++ΠΠ°ΠΊ ΠΏΠΎΠ΄Π΅Π»ΠΈΡΡΡΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΌΠ΅ΠΆΠ΄Ρ ΠΏΡΠΎΠ΅ΠΊΡΠ°ΠΌΠΈ Π² Microsoft SQL Server Reporting Services 2005? - sql-server-2005ΠΡΠ²ΠΎΠ΄ WWW-Π°ΡΡΠ΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΈ - httpΠ‘ΠΊΡΡΡΠΈΠ΅ ΡΡΠΎΠ»Π±ΡΠΎΠ² Π² ΡΠ°Π±Π»ΠΈΡΠ΅ Π΄Π°Π½Π½ΡΡ Microsoft Access 2007 Ρ ΠΏΠΎΠΌΠΎΡΡΡ VBA - vbaThe pains of creating a global application - web-applicationsExtracting two numbers from a string - javaHow to process POSTed XML through a Sinatra Ruby application - ruby ββ| fooobar.comSOAP request from AutoLISP / AutoCAD macro - soapΠΊΠ°ΠΊ ΡΠ΄Π΅Π»Π°ΡΡ ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΡΠΏΠΈΡΠ°Π»ΡΠ½ΠΎΠΉ Π³Π°Π»Π°ΠΊΡΠΈΠΊΠΈ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ ΡΠΎΡΠ΅ΠΊ Π΄Π°Π½Π½ΡΡ ? - arraysWhat is the fastest way to parallelize code? - parallel-processingAll Articles