A system, method and storage medium for coping with application crash
Through the combination of crash signal acquisition, exception handling and restart modules, the problem of manually closing the application after crash is solved, and the rapid automatic restart is achieved, which improves the restart speed after the application crash.
Patent Information
- Application Number
- CN202211213740.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2042-09-30
AI Technical Summary
In the prior art, after the application crashes, an error report box is manually processed to close the application process, resulting in a slow restart.
Provide a system and method to deal with application crashes, including crash signal acquisition module, crash exception handling module and restart module. The crash signal acquisition module obtains the crash signal. The crash exception handling module closes the main program according to the signal and outputs the restart signal, restarts. The module restarts the main program according to the restart signal, avoids the system generating error report boxes, reduces manual operation steps and improves the restart speed.
It realizes automatic closing of the main program and quick restart after the application crashes, avoiding manual manual operations, improving the restart speed after crashes, and reducing free time in the process.
Smart Images

Figure CN115525464B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic devices, and in particular to a system, method and storage medium for coping with application crashes. Background Art
[0002] With the development of the Internet, various applications have emerged. In order to meet the needs of users, applications with different functions are constantly being developed, which greatly facilitates the life and work of users. At the same time, it also causes users to need to use a large number of applications.
[0003] At present, in order to improve the user experience, applications are required to run uninterruptedly. However, due to various reasons such as hardware, software or improper operation, applications often crash probabilistically, and an error report box will pop up after the application crashes, preventing the application process from exiting after the crash. Only when the user manually closes the error report box will the crashed application process be closed. In other words, after the application crashes, the error report box needs to be manually processed to close the application process.
[0004] Therefore, in the prior art, after an application crashes, there is a problem that an error report box needs to be manually processed before the application can be closed, which results in a slow restart speed after the main program crashes. Summary of the invention
[0005] In view of this, it is necessary to provide a system, method and storage medium for coping with application crashes, so as to solve the problem in the prior art that after an application crashes, an error report box needs to be manually processed before the application can be closed.
[0006] In order to solve the above problem, the present invention provides a system for coping with application crash, comprising:
[0007] A crash signal collection module is used to obtain crash signals of applications;
[0008] A crash exception processing module, coupled to the crash signal acquisition module, for closing the main program according to the crash signal and outputting a restart signal;
[0009] The restart module is coupled to the crash exception handling module and is used to restart the main program according to the restart signal.
[0010] Furthermore, the crash signal collection module includes a waiting unit, which is used to obtain the crash signal of the application program according to the running state of the main program.
[0011] Furthermore, the crash exception handling module includes a crash exception handling unit and a state determination unit, wherein the crash exception handling unit is used to close the main program according to the crash signal, and the state determination unit is used to output a restart signal according to the on / off state of the main program.
[0012] Furthermore, the restart module includes a process creation unit, which is used to start the main program according to the restart signal.
[0013] In order to solve the above problem, the present invention also provides a method for dealing with application crashes, comprising:
[0014] Get the application's crash signal;
[0015] Close the main program according to the crash signal and output a restart signal;
[0016] Restart the main program according to the restart signal.
[0017] Furthermore, the crash signal of the application is obtained, including:
[0018] Set the waiting function and obtain the running status of the main program according to the waiting function;
[0019] According to the running status of the main program, determine whether to output the crash signal of the application;
[0020] When the main program is in the crash state, the crash signal of the application is output; when the main program is in the normal state, the current state is maintained.
[0021] Further, closing the main program according to the crash signal and outputting a restart signal includes:
[0022] Set up crash exception handling function and state judgment function;
[0023] The crash exception handling function outputs instructions to close the main program according to the crash signal;
[0024] The state judgment function determines whether to output a restart signal according to the opening and closing state of the main program;
[0025] When the main program's on / off state is closed, a restart signal is output; when the main program's on / off state is open, the current running state is maintained.
[0026] Furthermore, the crash exception handling function is set based on the SetUnhandledExceptionFilter function.
[0027] Further, restarting the main program according to the restart signal includes:
[0028] Set the restart function and output the instruction to restart the main program according to the restart signal.
[0029] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program runs, the device where the computer-readable storage medium is located is controlled to execute the method for coping with application crashes as described above.
[0030] The beneficial effect of adopting the above technical solution is: the present invention provides a system, method and storage medium for dealing with application crashes, the system comprising: a crash signal acquisition module, for acquiring the crash signal of the application; a crash exception handling module, coupled to the crash signal acquisition module, for closing the main program according to the crash signal and outputting a restart signal; a restart module, coupled to the crash exception handling module, for restarting the main program according to the restart signal. The crash exception handling module guides the closing of the main program according to the crash signal, thereby avoiding the system from generating an error report box and reducing the steps of manual operation; the restart module restarts the main program after confirming that the main program is completely closed, thereby restarting the application, which not only avoids the problem of improper operation, but also realizes the time coordination of the closing and restarting process of the main program, which can reduce the idle time in the process, thereby effectively improving the restart speed after the main program crashes. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A schematic diagram of the structure of an embodiment of a system for coping with application crashes provided by the present invention;
[0032] Figure 2 A flow chart of an embodiment of a method for coping with application crashes provided by the present invention;
[0033] Figure 3 A schematic diagram of a flow chart of an embodiment of obtaining a crash signal of an application program provided by the present invention;
[0034] Figure 4 A flowchart of an embodiment of closing a main program according to a crash signal and outputting a restart signal provided by the present invention. DETAILED DESCRIPTION
[0035] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0036] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0037] In the description of the present invention, reference to an "embodiment" means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive of other embodiments. It is explicitly and implicitly understood by those skilled in the art that the described embodiments may be combined with other embodiments.
[0038] In the description of the present invention, the execution order of the steps between the processes is not limited to the order in which they appear in the text, and the corresponding order can be adjusted in sequence or appear in parallel.
[0039] Before describing the embodiment, the main program, the daemon, and SetUnhandledExceptionFilter are explained:
[0040] The main program is the program that may crash probabilistically.
[0041] A daemon is a program that can obtain some running parameters of the main program.
[0042] SetUnhandledExceptionFilter refers to the exception capture function set in the Windows system. When an exception that causes a crash occurs in the main program process, the system will call the exception handling function set by SetUnhandledExceptionFilter.
[0043] Currently, when an application crashes probabilistically, the system will pop up an error report box to prevent the application process from exiting, thereby outputting a prompt of the application crash. In response to this prompt, the application process can only be closed after the error report box is manually processed. However, in the case of an application crash, users are more concerned about the recovery of the application or not affecting the use of other applications.
[0044] Therefore, when dealing with application crashes, the prior art has the problem that an error report box needs to be manually processed before the application can be closed.
[0045] In order to solve the above problems, the present invention provides a system, method and storage medium for coping with application crashes, which are described in detail below.
[0046] like Figure 1 As shown, Figure 1 This is a schematic diagram of a structure of an embodiment of a system for coping with application crashes provided by the present invention. The system 100 for coping with application crashes includes:
[0047] A crash signal collection module 101 is used to obtain crash signals of an application program;
[0048] The crash exception processing module 102 is coupled to the crash signal collection module 101 and is used to close the main program according to the crash signal and output a restart signal;
[0049] The restart module 103 is coupled to the crash exception handling module 102 and is used to restart the main program according to the restart signal.
[0050] In this embodiment, first, the crash signal acquisition module 101 obtains the crash signal of the application according to the running parameters of the application; then, the crash exception handling module 102 is activated under the action of the crash signal, and outputs an instruction to close the main program according to the crash signal, and outputs a signal to restart the main program after the main program is completely closed; finally, the restart module 103 restarts the main program under the drive of the restart signal.
[0051] In this embodiment, by setting up a crash exception handling module 102, an instruction to close the main program is immediately issued after receiving the crash signal of the application, so that the system receives the "close the main program" instruction before the system issues an error report box, thereby avoiding the system from issuing an error report box, thereby completely avoiding the problem of needing to manually close the error report box; further, the crash exception handling module 102 in this embodiment also outputs a restart signal after confirming that the main program is completely closed, and the restart module 103 restarts the main program according to the restart signal, thereby restarting the application.
[0052] In this embodiment, the application includes a main program and a daemon program. The main program is the main part of the application and is related to the operation of the application; the daemon program is the marginal part of the application and is not related to the operation of the main program.
[0053] As a preferred embodiment, the crash signal collection module 101 includes a waiting unit, which is used to obtain the crash signal of the application program according to the running state of the main program.
[0054] As a preferred embodiment, the crash exception handling module 102 includes a crash exception handling unit and a state determination unit, wherein the crash exception handling unit is used to close the main program according to the crash signal, and the state determination unit is used to output a restart signal according to the opening and closing state of the main program.
[0055] As a preferred embodiment, the restart module 103 includes a process creation unit, which is used to start the main program according to the restart signal.
[0056] In order to solve the above problems, the present invention provides a method for dealing with application crashes, such as Figure 2 As shown, Figure 2 A flow chart of an embodiment of a method for coping with application crashes provided by the present invention includes:
[0057] Step S101: Acquire a crash signal of an application program.
[0058] Step S102: closing the main program according to the crash signal and outputting a restart signal.
[0059] Step S103: restart the main program according to the restart signal.
[0060] In this embodiment, first, a crash signal of the application is obtained; then, the main program is closed according to the crash signal, and a restart signal is output after the main program is completely closed; finally, the main program is restarted according to the restart signal.
[0061] In this embodiment, the main program in the application is immediately closed after receiving the crash signal of the application, thereby avoiding the system from generating an error report box; then, a restart signal is output after the main program is completely closed, and the main program is restarted according to the restart signal, thereby improving the speed of restarting the main program after the crash.
[0062] As a preferred embodiment, in step S101, in order to obtain the crash signal of the application, such as Figure 3 As shown, Figure 3 A schematic diagram of a flow chart of an embodiment of obtaining a crash signal of an application provided by the present invention includes:
[0063] Step S111: Set a waiting function, and obtain the running status of the main program according to the waiting function.
[0064] Step S112: judging whether to output a crash signal of the application program according to the running state of the main program.
[0065] Step S113: when the running state of the main program is crash exit, output the crash signal of the application program; when the running state of the main program is normal operation, keep the current running state.
[0066] In this embodiment, by setting a waiting function, the running parameters of the main program are obtained, and thus the running status of the main program is obtained accordingly; then, according to the running status of the main program, when the running status of the main program is a crash exit, the crash signal of the application is output; when the running status of the main program is running normally, the current running status is maintained.
[0067] In a specific embodiment, the waiting function adopts the WaitForSingleObject function, with the handle of the main program as the first parameter, and INFINITE as the second parameter, indicating that the waiting time is infinite.
[0068] If the main program crashes and exits, the WaitForSingleObject function will return immediately, indicating that the state of the object pointed to by handle has changed, and output a crash signal of the application; if the main program runs normally, WaitForSingleObject will keep waiting.
[0069] Specifically, the relevant pseudo code running in the waiting function is as follows:
[0070]
[0071] As a preferred embodiment, in step S102, in order to close the main program according to the crash signal and output a restart signal, such as Figure 4 As shown, Figure 4 A flow chart of an embodiment of closing a main program according to a crash signal and outputting a restart signal provided by the present invention includes:
[0072] Step S121: Setting a crash exception handling function and a state determination function.
[0073] Step S122: The crash exception handling function outputs an instruction to close the main program according to the crash signal.
[0074] Step S123: The state determination function determines whether to output a restart signal according to the on / off state of the main program.
[0075] Step S124: when the opening and closing state of the main program is closed, a restart signal is output; when the opening and closing state of the main program is open, the current running state is maintained.
[0076] In this embodiment, by setting a crash exception handling function, an instruction to close the main program can be output in time when a crash signal is obtained; by setting a state judgment function, the opening and closing status of the main program can be obtained in time, and a restart signal can be output after the main program is completely closed, so as to output the restart signal at the fastest speed, thereby improving the restart speed after the main program crashes.
[0077] As a preferred embodiment, in step S121, the crash exception handling function is set based on the SetUnhandledExceptionFilter function. The SetUnhandledExceptionFilter function, which is designated by the system to be started after the application crashes, is used as the basis for setting the crash exception handling function, which can better meet the adaptability and avoid unstable use process caused by low adaptability.
[0078] In a specific embodiment, the crash exception handling function adopts the UnhandledExceptionFilter function. After capturing the crash signal, the system calls the UnhandledExceptionFilter function. If the function directly returns EXCEPTION_EXECUTE_HANDLER, it means that the exception has been handled. In this way, the system will not create an error report box process, thereby avoiding manual operation to handle the error report box.
[0079] Specifically, the relevant pseudo code of the crash exception handling function is as follows:
[0080] (1) Define a crash exception handling function
[0081]
[0082] (2) Register a crash exception handling function
[0083] begin:
[0084] SetUnhandledExceptionFilter(UnhandledExcepFilter);
[0085] End;
[0086] As a preferred embodiment, in step S103, in order to restart the main program according to the restart signal, a restart function is set, and an instruction to restart the main program is output according to the restart signal.
[0087] In this embodiment, the restart signal is obtained in time by the restart function, and the instruction to restart the main program is output according to the restart signal, which can reduce the time of capturing the restart signal and effectively improve the restart speed after the main program crashes.
[0088] In a specific embodiment, the restart function uses the CreateProcess function. After capturing the restart signal, the CreateProcess function is called to start the main program and the handle of the main program returned by the CreateProcess function is saved, wherein the handle is stored in a variable named Handle.
[0089] Through the above method, after detecting the signal of application crash, first, the crash exception handling function in the crash exception handling module is used to guide the main program to close, thereby avoiding the system from generating an error report box and reducing the steps of manual operation; then, after confirming that the main program is completely closed, the main program is restarted to restart the application, which not only avoids the problem of improper operation, but also guides the main program to restart based on the restart function in the restart module, realizes the time coordination of the main program closing and restarting process, can reduce the idle time in the process, and thus effectively improves the restart speed of the main program after the crash.
[0090] In order to solve the above problems, the present invention also provides a computer-readable storage medium on which a computer program is stored, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the method for dealing with application crashes as described in any of the above technical solutions.
[0091] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0092] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A system for dealing with application crashes, characterized in that: include: A crash signal collection module is used to obtain crash signals of applications; A crash exception processing module, coupled to the crash signal acquisition module, configured to close the main program according to the crash signal and output a restart signal; A restart module, coupled to the crash exception handling module, and configured to restart the main program according to the restart signal; The crash signal acquisition module includes a waiting unit, which is used to obtain the crash signal of the application according to the running state of the main program, specifically including: setting a waiting function, and obtaining the running state of the main program according to the waiting function; judging whether to output the crash signal of the application according to the running state of the main program; when the running state of the main program is crash exit, outputting the crash signal of the application; when the running state of the main program is normal operation, maintaining the current running state; wherein the waiting function adopts the WaitForSingleObject function, with the handle of the main program as the first parameter, the first parameter is handle, and INFINITE as the second parameter, indicating that the waiting time is infinite.
2. The system for coping with application crash according to claim 1, characterized in that: The crash exception handling module includes a crash exception handling unit and a state determination unit, wherein the crash exception handling unit is used to close the main program according to the crash signal, and the state determination unit is used to output the restart signal according to the opening and closing state of the main program.
3. The system for coping with application crash according to claim 1, characterized in that: The restart module includes a process creation unit, which is used to start the main program according to the restart signal.
4. A method for dealing with application crashes, characterized in that: include: Get the application's crash signal; Closing the main program according to the crash signal and outputting a restart signal; restarting the main program according to the restart signal; Get application crash signals, including: Setting a waiting function, and obtaining the running status of the main program according to the waiting function; Determining whether to output the crash signal of the application program according to the running state of the main program; When the running state of the main program is crash exit, the crash signal of the application is output; when the running state of the main program is normal, the current running state is maintained; wherein, the waiting function adopts the WaitForSingleObject function, with the handle of the main program as the first parameter, the first parameter is handle, and INFINITE as the second parameter, indicating that the waiting time is infinite.
5. The method for coping with application crash according to claim 4, characterized in that: Closing the main program according to the crash signal and outputting a restart signal includes: Set up crash exception handling function and state judgment function; The crash exception processing function outputs an instruction to close the main program according to the crash signal; The state determination function determines whether to output the restart signal according to the on / off state of the main program; When the opening and closing state of the main program is closed, the restart signal is output; when the opening and closing state of the main program is open, the current running state is maintained.
6. The method for coping with application crash according to claim 5, characterized in that: The crash exception handling function is set based on the SetUnhandledExceptionFilter function.
7. The method for coping with application crash according to claim 4, characterized in that: Restarting the main program according to the restart signal includes: A restart function is set to output an instruction to restart the main program according to the restart signal.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program runs, the device where the computer-readable storage medium is located is controlled to execute the method for coping with application crashes according to any one of claims 4 to 7.
