A method, apparatus, and electronic device for process identification

By receiving process query and startup instructions, obtaining the identification information of the nginx process and obtaining absolute paths in the virtual file system, the problem of low process recognition efficiency in the existing technology is solved, and the precise identification and control of the process is realized.

CN118885998BActive Publication Date: 2025-07-11BEIJING HOLYZONE TECH CORP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410945492.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2025-07-11
Estimated Expiration
2044-07-15

AI Technical Summary

Technical Problem

In the prior art, the process identification efficiency and accuracy of relying on the executable program search path method provided by the operating system is low, making it difficult to accurately identify and control the process, especially in the case of nginx process.

Method used

By receiving process query and startup instructions, we obtain the process identification information, and obtain the absolute paths of the executable files and configuration files in the virtual file system, and use path matching and directory determination methods to achieve accurate identification of the process.

Benefits of technology

It realizes accurate identification and control of processes, and can uniquely determine the process in the running state when the path in the process startup instruction is a relative path.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885998B_ABST
    Figure CN118885998B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for process identification. The method includes: receiving a process query instruction and an instruction for receiving a process start instruction; according to the process query instruction, identifying a process in a running state as a process to be identified, and obtaining identification information of the process to be identified; according to the instruction for receiving a process start instruction, obtaining the process start instruction of the process to be identified; from the process start instruction of the process to be identified, obtaining the paths of the executable file and the configuration file of the process to be identified; when the paths of the executable file and the configuration file are both relative paths, obtaining the absolute path of the executable file of the process to be identified; matching the absolute path of the executable file with the relative path to determine the current directory of the relative path of the executable file; according to the upper-level directory of the relative path of the executable file, determining the absolute path of the configuration file of the process to be identified; and identifying the process to be identified according to the absolute paths of the executable file and the configuration file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a method, apparatus, and electronic device for process identification. Background Art

[0002] Multiple processes usually run on a host simultaneously, and these processes are started with different working paths and execution paths respectively. To achieve precise management of processes, the first thing to achieve is precise identification of processes. The inventor found that the currently used method for identifying processes usually relies on the method of searching for executable program paths provided by the operating system. However, this method that relies on the executable program search path provided by the operating system usually has low efficiency in identifying processes. Taking the nginx process as an example, in the case where the directory of the nginx process is added to the PATH environment variable and the user directly enters the command: "nginx" in the operating system to start the nginx process, the efficiency and accuracy of the existing technology in identifying the nginx process are very low, and thus it is also very difficult to achieve precise control of the nginx process. To sum up, the existing technology currently has the problem that precise identification and control of processes cannot be achieved. Summary of the Invention

[0003] Embodiments of the present invention provide a method, apparatus, and electronic device for process identification to solve the problem in the existing technology that precise identification and control of processes cannot be achieved.

[0004] The specific technical solutions are as follows:

[0005] In a first aspect, embodiments of the present invention provide a method for process identification. The method is applied to a virtual machine or a hardware server and includes the following steps:

[0006] Receive a process query instruction and an instruction for receiving a process start instruction respectively; wherein, the process start instruction is an instruction input when starting a process;

[0007] According to the process query instruction, confirm the processes in the running state in itself as processes to be identified, and obtain the identification information of the processes to be identified;

[0008] According to the instruction for receiving the process start instruction, obtain the process start instruction of the process to be identified; wherein, the process start instruction of the process to be identified includes: the start instruction of the executable file corresponding to the process to be identified, the start instruction of the configuration file corresponding to the process to be identified; the start instruction of the executable file contains the path of the executable file; the start instruction of the configuration file contains the path of the configuration file;

[0009] Obtain the paths of the executable file and the configuration file corresponding to the process to be recognized from the process startup instruction of the process to be recognized;

[0010] When the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be recognized are both relative paths, obtain the absolute path of the executable file corresponding to the process to be recognized from the virtual file system according to the identification information of the process to be recognized;

[0011] Match the absolute path of the executable file corresponding to the process to be recognized with the relative path of the executable file corresponding to the process to be recognized to determine the current directory of the relative path of the executable file;

[0012] Determine the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file;

[0013] Determine the absolute path of the configuration file corresponding to the process to be recognized according to the upper-level directory of the relative path of the executable file;

[0014] Recognize the process to be recognized according to the absolute paths of the executable file and the configuration file corresponding to the process to be recognized.

[0015] Optionally, the method further includes:

[0016] When the paths of the executable file and the configuration file in the process startup instruction of the process to be recognized are absolute paths, obtain the absolute paths of the executable file and the configuration file, and recognize the process to be recognized according to the absolute paths of the executable file and the configuration file.

[0017] Optionally, the steps of respectively receiving a process query instruction and an instruction for receiving a process startup instruction include:

[0018] Respectively receive a process query instruction and an instruction for receiving an nginx process startup instruction.

[0019] Optionally, the step of, according to the process query instruction, determining the process in its own running state as the process to be recognized and obtaining the identification information of the process to be recognized includes:

[0020] According to the process query instruction, determine the running nginx process in its own as the process to be recognized and obtain the identification information of the process to be recognized.

[0021] Optionally, before the step of, according to the instruction for receiving the process startup instruction, obtaining the process startup instruction of the process to be recognized, further includes:

[0022] Receive the process startup instruction issued by the user, start the corresponding process according to the process startup instruction, and save the process startup instruction.

[0023] In a second aspect, an embodiment of the present invention provides a device for process identification, the device including:

[0024] An instruction receiving module, configured to respectively receive a process query instruction and an instruction for receiving a process startup instruction; wherein, the process startup instruction is an instruction input when starting a process;

[0025] A confirmation module, configured to confirm the processes in its own running state as processes to be identified according to the process query instruction, and obtain the identification information of the processes to be identified;

[0026] An instruction obtaining module, configured to obtain the process startup instruction of the process to be identified according to the instruction for receiving the process startup instruction; wherein, the process startup instruction of the process to be identified includes: the startup instruction of the executable file corresponding to the process to be identified, the startup instruction of the configuration file corresponding to the process to be identified; the startup instruction of the executable file contains the path of the executable file; the startup instruction of the configuration file contains the path of the configuration file;

[0027] A path obtaining module, configured to obtain the paths of the executable file and the configuration file corresponding to the process to be identified from the process startup instruction of the process to be identified;

[0028] An obtaining module, configured to, when the paths of the executable file and the configuration file obtained from the process startup instruction of the process to be identified are both relative paths, obtain the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified;

[0029] A matching module, configured to match the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified, and determine the current directory of the relative path of the executable file;

[0030] A first determination module, configured to determine the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file;

[0031] A second determination module, configured to determine the absolute path of the configuration file corresponding to the process to be identified according to the upper-level directory of the relative path of the executable file;

[0032] An identification module, configured to identify the process to be identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified.

[0033] Optionally, the obtaining module is further configured to:

[0034] When the paths of the executable file and the configuration file in the process startup instruction of the process to be recognized are absolute paths, obtain the absolute paths of the executable file and the configuration file, and start the recognition module.

[0035] Optionally, the instruction receiving module is specifically configured to:

[0036] Receive a process query instruction and a nginx process startup instruction respectively.

[0037] Optionally, the confirmation module is specifically configured to:

[0038] According to the process query instruction, confirm the nginx process in the running state in itself as the process to be recognized, and obtain the identification information of the process to be recognized.

[0039] Optionally, the device further includes: a startup saving module, configured to:

[0040] Receive a process startup instruction issued by a user, start a corresponding process according to the process startup instruction, and save the process startup instruction.

[0041] In a third aspect, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;

[0042] The memory is used to store a computer program;

[0043] When the processor is used to execute the program stored on the memory, the method steps of the process recognition described in the first aspect above are implemented.

[0044] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the method steps of the process recognition described in the first aspect above are implemented.

[0045] The method for process identification provided by the embodiments of the present invention is applied to a virtual machine or a hardware server, and can receive a process query instruction and an instruction for receiving a process start instruction respectively; according to the process query instruction, confirm the processes in its own running state as processes to be identified, and obtain the identification information of the processes to be identified; according to the instruction for receiving the process start instruction, obtain the process start instruction of the process to be identified; from the process start instruction of the process to be identified, obtain the paths of the executable file and the configuration file corresponding to the process to be identified; when the paths of the executable file and the configuration file obtained from the process start instruction of the process to be identified are both relative paths, according to the identification information of the process to be identified, obtain the absolute path of the executable file corresponding to the process to be identified from the virtual file system; match the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified to determine the current directory of the relative path of the executable file; according to the current directory of the relative path of the executable file, determine the upper-level directory of the relative path of the executable file; according to the upper-level directory of the relative path of the executable file, determine the absolute path of the configuration file corresponding to the process to be identified; identify the process to be identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified. Thus, it can be seen that when the paths of the executable file and the configuration file in the process start instruction of the process to be identified are both relative paths, by using the method provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained, and then, according to the absolute paths of the executable file and the configuration file of the process, a process in the running state can be uniquely determined. That is to say, the method provided by the embodiments of the present invention can achieve accurate identification of the process, and further can achieve accurate control of the process. In summary, the method provided by the embodiments of the present invention can solve the problem in the prior art that accurate identification and control of the process cannot be achieved.

[0046] Other features and advantages of the present invention will be described in the following specification, and, in part, will be obvious from the specification, or will be understood by implementing the present invention. The objectives and other advantages of the present invention can be realized and obtained by the structures specifically pointed out in the written specification, claims, and drawings.

[0047] The technical solution of the present invention will be further described in detail below through the drawings and embodiments. Description of the Drawings

[0048] The drawings are used to provide a further understanding of the present invention, and constitute a part of the specification. They are used to explain the present invention together with the embodiments of the present invention, and do not constitute a limitation to the present invention. In the drawings:

[0049] Figure 1 It is a schematic flowchart of a method for process identification provided by an embodiment of the present invention;

[0050] Figure 2 Another schematic flowchart of the process identification method provided by the embodiment of the present invention;

[0051] Figure 3 A schematic structural diagram of the process identification device provided by the embodiment of the present invention;

[0052] Figure 4 A schematic internal structure diagram of the electronic device provided by the embodiment of the present invention. Specific embodiments

[0053] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are only for the purpose of illustrating and explaining the present invention, and are not intended to limit the present invention.

[0054] Figure 1 A schematic flowchart of a method for identifying a process provided by the embodiment of the present invention. The method provided by the embodiment of the present invention is applied to a virtual machine or a hardware server, such as Figure 1 As shown, the method includes:

[0055] S101: Receive a process query instruction and an instruction for receiving a process start instruction respectively; wherein, the process start instruction is an instruction input when starting a process;

[0056] In a specific embodiment, the step of receiving a process query instruction and an instruction for receiving a process start instruction respectively may include:

[0057] Receive a process query instruction and an instruction for receiving a nginx process start instruction respectively.

[0058] Nginx (engine X) is a lightweight and high-performance HTTP server and reverse proxy server, and is also an IMAP / POP3 / SMTP proxy server.

[0059] In practical applications, the user can input the instruction: ps aux|grep 'nginx:master process' in the operating system of the virtual machine or the hardware server to query the processes running in the operating system of the virtual machine or the hardware server, and filter out the running information of the nginx master process from them, and obtain the start instruction of the nginx process.

[0060] S102: According to the process query instruction, confirm the processes in the running state in itself as the processes to be identified, and obtain the identification information of the processes to be identified;

[0061] Here, the "itself" refers to the operating system of the virtual machine or the hardware server. In a specific embodiment, it may be a linux operating system.

[0062] In a specific embodiment, according to the process query instruction, the step of identifying the processes in its own running state as the processes to be identified and obtaining the identification information of the processes to be identified may include:

[0063] According to the process query instruction, identify the nginx process in its own running state as the process to be identified and obtain the identification information of the process to be identified.

[0064] S103: According to the instruction for obtaining the process start instruction, obtain the process start instruction of the process to be identified; wherein, the process start instruction of the process to be identified includes: the start instruction of the executable file corresponding to the process to be identified, the start instruction of the configuration file corresponding to the process to be identified; the start instruction of the executable file includes the path of the executable file; the start instruction of the configuration file includes the path of the configuration file;

[0065] Each nginx process has its own executable file, working path, and configuration file. The executable file is the nginx program, which indicates who the process is and which program it is. The working path indicates where the root directory of the current process is located. The configuration file determines what services the process can provide.

[0066] In practical applications, before the step of obtaining the process start instruction of the process to be identified according to the instruction for obtaining the process start instruction, it may further include:

[0067] Receive the process start instruction issued by the user, start the corresponding process according to the process start instruction, and save the process start instruction.

[0068] S104: Obtain the paths of the executable file and the configuration file corresponding to the process to be identified from the process start instruction of the process to be identified;

[0069] S105: When the paths of the executable file and the configuration file obtained from the process start instruction of the process to be identified are both relative paths, obtain the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified;

[0070] In a specific embodiment, the method provided by the embodiment of the present invention further includes:

[0071] When the paths of the executable file and the configuration file in the process start instruction of the process to be identified are absolute paths, obtain the absolute paths of the executable file and the configuration file, and identify the process to be identified according to the absolute paths of the executable file and the configuration file.

[0072] The absolute paths of the executable file and the configuration file of the ngnix process can uniquely determine an ngnix process in a running state.

[0073] Users must start the nginx process through a process startup instruction. Generally, there are three ways to start the nginx process:

[0074] 1. Start the nginx process using the absolute path of the nginx process. That is to say, the process startup instruction includes: the absolute paths of the executable file and the configuration file corresponding to the nginx process. In this case, for the method provided in the embodiments of the present invention, it only needs to directly obtain the absolute paths of the executable file and the configuration file corresponding to the nginx process from the process startup instruction; and then identify the nginx process according to the absolute paths of the executable file and the configuration file corresponding to the nginx process.

[0075] 2. Start the nginx process using the relative path of the nginx process. In this case, for the method provided in the embodiments of the present invention, the absolute paths of the executable file and the configuration file corresponding to the nginx process can be obtained from the virtual file system according to the identification information of the nginx process; and then identify the nginx process according to the absolute paths of the executable file and the configuration file corresponding to the nginx process. In a specific embodiment, the absolute paths of the executable file and the configuration file corresponding to the nginx process can be obtained from the proc file system (a virtual file system) according to the identification information of the nginx process.

[0076] 3. When the directory where the nginx process is located is added to the PATH environment variable, the user directly enters the command "nginx" in the operating system to start the nginx process. In this case, the method provided by the embodiments of the present invention needs to first obtain the absolute path of the executable file of the nginx process from the virtual file system according to the identification information of the nginx process; then match the absolute path of the executable file of the nginx process with the relative path of the executable file of the nginx process to determine the current directory of the relative path of the executable file of the nginx process, where the relative path of the executable file of the nginx process is obtained from the process startup instruction corresponding to the nginx process; determine the upper-level directory of the relative path of the executable file of the nginx process according to the current directory of the relative path of the executable file of the nginx process; determine the absolute path of the configuration file of the nginx process according to the upper-level directory of the relative path of the executable file of the nginx process; and then identify the nginx process according to the absolute paths of the executable file and the configuration file corresponding to the nginx process. The PATH environment variable is to store specific paths in the system cache. When running some programs, the system will first search for the program from the current path. If it cannot be found, it will enter the paths specified in the PATH to find the corresponding file and run it.

[0077] S106: Match the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified to determine the current directory of the relative path of the executable file;

[0078] In a specific embodiment, it is to match the string of the absolute path of the executable file of the nginx process with the string of the relative address of the executable file of the nginx process to determine the current directory of the relative path of the executable file of the nginx process.

[0079] Absolute path: It directly indicates the specific location of the file on the hard disk or the complete path with reference to the root directory of the Web site. The absolute path is a fixed directory, which is intuitive and clear, but the files referenced by the web pages cannot be moved casually. When multiple web pages reference the same file, the absolute paths used are the same.

[0080] Relative path: It omits information such as the disk drive letter and computer name, and establishes a reference root directory with reference to the folder location where the web page referencing the file is located. When web pages saved in different directories reference the same file, the relative paths used are different. In the relative path:

[0081] / represents the root directory;

[0082] . / represents the directory where the current file is located (which can be omitted);

[0083] ... / represents the parent directory of the directory where the current file is located;

[0084] ... / ... / represents the grandparent directory of the directory where the current file is located;

[0085] ... / ... / ... / and so on.

[0086] S107: Determine the parent directory of the relative path of the executable file according to the current directory of the relative path of the executable file;

[0087] S108: Determine the absolute path of the configuration file corresponding to the process to be recognized according to the parent directory of the relative path of the executable file;

[0088] S109: Recognize the process to be recognized according to the absolute paths of the executable file and the configuration file corresponding to the process to be recognized.

[0089] by Figure 1It can be seen that the method for process identification provided by the embodiments of the present invention is applied to a virtual machine or a hardware server, and can receive a process query instruction and an instruction for receiving a process start instruction respectively; according to the process query instruction, confirm the processes in the running state in itself as the processes to be identified, and obtain the identification information of the processes to be identified; according to the instruction for receiving the process start instruction, obtain the process start instruction of the process to be identified; from the process start instruction of the process to be identified, obtain the paths of the executable file and the configuration file corresponding to the process to be identified; when the paths of the executable file and the configuration file obtained from the process start instruction of the process to be identified are both relative paths, according to the identification information of the process to be identified, obtain the absolute path of the executable file corresponding to the process to be identified from the virtual file system; match the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified to determine the current directory of the relative path of the executable file; determine the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file; determine the absolute path of the configuration file corresponding to the process to be identified according to the upper-level directory of the relative path of the executable file; identify the process to be identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified. Thus, it can be seen that when the paths of the executable file and the configuration file in the process start instruction of the process to be identified are both relative paths, by using the method provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained, and then, a process in the running state can be uniquely determined according to the absolute paths of the executable file and the configuration file of the process. That is to say, the method provided by the embodiments of the present invention can achieve accurate identification of processes, and further can achieve accurate control of processes. In summary, it can be seen that the method provided by the embodiments of the present invention can solve the problem in the prior art that accurate identification and control of processes cannot be achieved.

[0090] Next, a practical example is given to further and more detailedly illustrate the method provided by the embodiments of the present invention. In this embodiment, the execution subject of the method provided by the embodiments of the present invention is a hardware server, and the operating system of the hardware server is the linux operating system; the process to be identified in this embodiment is the running ngnix process; and in this embodiment, the directory where the nginx process is located is added to the PATH environment variable. See Figure 2 , the process of this embodiment is as follows:

[0091] S201: Receive a process query instruction and an instruction for receiving a nginx process start instruction respectively;

[0092] Among them, the process start instruction is the instruction input when starting a process.

[0093] For example, the user can enter the instruction "ps aux|grep 'nginx:master process'" in the operating system of the virtual machine or the hardware server to query the processes running in the operating system of the hardware server, filter out the running information of the nginx master process from them, and obtain the startup instruction of the nginx process.

[0094] S202: According to the process query instruction, confirm the nginx processes in the running state in itself as the processes to be recognized, and obtain the identification information of the nginx processes to be recognized;

[0095] Specifically, it can be: According to the process query instruction, the operating system of the hardware server confirms the nginx processes in the running state in itself as the processes to be recognized, and obtains the identification information of the nginx processes to be recognized.

[0096] Of course, there may be multiple nginx processes running in the operating system, so it is necessary to obtain all the running nginx processes in the operating system and confirm them all as the nginx processes to be recognized.

[0097] S203: According to the instruction for obtaining the process startup instruction, obtain the process startup instruction of the nginx process to be recognized;

[0098] Among them, the process startup instruction of the nginx process includes: the startup instruction of the executable file corresponding to the nginx process, and the startup instruction of the configuration file corresponding to the nginx process; the startup instruction of the executable file contains the path of the executable file; the startup instruction of the configuration file contains the path of the configuration file.

[0099] Of course, in actual applications, when the user sends a process startup instruction to the operating system, the process startup instruction will be saved for subsequent use.

[0100] S204: From the process startup instruction of the nginx process to be recognized, obtain the paths of the executable file and the configuration file of the nginx process to be recognized;

[0101] In this embodiment, in the process startup instruction of the nginx process to be recognized, the paths of the executable file and the configuration file are both relative paths, so steps S205 - S209 need to be executed.

[0102] In other embodiments, if the paths of the executable file and the configuration file in the process startup instruction of the nginx process to be recognized are both absolute paths, then directly obtain the absolute paths of the executable file and the configuration file of the nginx process to be recognized from the process startup instruction of the nginx process to be recognized, and recognize the nginx process to be recognized according to the absolute paths of the executable file and the configuration file of the nginx process to be recognized.

[0103] S205: Obtain the absolute path of the executable file corresponding to the nginx process to be recognized from the proc file system according to the identification information of the nginx process to be recognized;

[0104] Specifically, the absolute path of the executable file corresponding to the nginx process is a string. For example, the absolute path is: user / srod / nginx.

[0105] S206: Match the absolute path of the executable file of the ngnix process to be recognized with the relative path of the executable file of the ngnix process to be recognized, and determine the current directory of the relative path of the executable file of the ngnix process to be recognized;

[0106] For example, in the process startup instruction of the nginx process to be recognized (in this embodiment, the paths of the executable file and the configuration file in the process startup instruction of the nginx process are both relative paths), the paths of the executable file and the configuration file are respectively:. / srod / nginx (relative path of the executable file);.. / edx / nginx (relative path of the configuration file). Match the absolute path of the executable file: user / srod / nginx with the relative path of the executable file:. / srod / nginx, and determine that the current directory of the relative path of the executable file of the ngnix process to be recognized is: user.

[0107] S207: Determine the upper-level directory of the relative path of the executable file of the ngnix process to be recognized according to the current directory of the relative path of the executable file of the ngnix process to be recognized;

[0108] For example: Determine the upper-level directory of the relative path of the executable file of the ngnix process to be recognized according to the current directory "user" of the relative path of the executable file of the ngnix process to be recognized.

[0109] S208: Determine the absolute path of the configuration file of the ngnix process to be recognized according to the upper-level directory of the relative path of the executable file of the ngnix process to be recognized;

[0110] S209: Identify the nginx process to be recognized based on the absolute paths of its executable file and configuration file.

[0111] In practical applications, after accurately identifying the nginx process, it is also possible to further control the nginx process according to actual needs. For example, the following management operations can be performed on Nginx: restart, start, force shutdown, graceful shutdown, reload configuration, smooth upgrade, upgrade rollback, output the existing configuration, or verify the correctness of the configuration, etc. Only by accurately identifying the nginx process can accurate control of the nginx process be achieved. Otherwise, there may be incorrect operations on the nginx process. For example, an incorrect shutdown operation may be performed on an nginx process that should not be shut down. After the misoperated nginx process is shut down, the original service will stop. In a production environment, such misoperations can lead to production accidents. Therefore, accurate control of the nginx process must be achieved.

[0112] From Figure 2 the embodiments shown, when the paths of the executable file and the configuration file in the process startup instruction of the process to be recognized are both relative paths, using the method provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained. Then, a process in the running state can be uniquely determined based on the absolute paths of the executable file and the configuration file of the process. That is to say, the method provided by the embodiments of the present invention can achieve accurate identification of the process, and thus can achieve accurate control of the process. In summary, the method provided by the embodiments of the present invention can solve the problem in the prior art that accurate identification and control of the process cannot be achieved.

[0113] Corresponding to Figure 1 the embodiments shown, the embodiments of the present invention also provide a device for process identification. As Figure 3 shown, the device includes: an instruction receiving module 301, a confirmation module 302, an instruction obtaining module 303, a path obtaining module 304, an obtaining module 305, a matching module 306, a first determination module 307, a second determination module 308, and an identification module 309. Among them,

[0114] The instruction receiving module 301 is used to respectively receive a process query instruction and an instruction for receiving a process startup instruction; among them, the process startup instruction is an instruction input when starting a process.

[0115] The confirmation module 302 is used to confirm the processes in its own running state as processes to be recognized according to the process query instruction, and obtain the identification information of the processes to be recognized.

[0116] An instruction acquisition module 303, configured to acquire a process start instruction of a process to be recognized according to an instruction for acquiring a process start instruction; wherein, the process start instruction of the process to be recognized includes: a start instruction of an executable file corresponding to the process to be recognized, a start instruction of a configuration file corresponding to the process to be recognized; the start instruction of the executable file includes the path of the executable file; the start instruction of the configuration file includes the path of the configuration file;

[0117] A path acquisition module 304, configured to acquire the paths of the executable file and the configuration file corresponding to the process to be recognized from the process start instruction of the process to be recognized;

[0118] An acquisition module 305, configured to, when the paths of the executable file and the configuration file acquired from the process start instruction of the process to be recognized are both relative paths, acquire the absolute path of the executable file corresponding to the process to be recognized from the virtual file system according to the identification information of the process to be recognized;

[0119] A matching module 306, configured to match the absolute path of the executable file corresponding to the process to be recognized with the relative path of the executable file corresponding to the process to be recognized to determine the current directory of the relative path of the executable file;

[0120] A first determination module 307, configured to determine the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file;

[0121] A second determination module 308, configured to determine the absolute path of the configuration file corresponding to the process to be recognized according to the upper-level directory of the relative path of the executable file;

[0122] A recognition module 309, configured to recognize the process to be recognized according to the absolute paths of the executable file and the configuration file corresponding to the process to be recognized.

[0123] Optionally, the acquisition module 305 is further configured to:

[0124] When the paths of the executable file and the configuration file in the process start instruction of the process to be recognized are absolute paths, acquire the absolute paths of the executable file and the configuration file, and start the recognition module 309.

[0125] Optionally, the instruction receiving module 301 is specifically configured to:

[0126] Receive a process query instruction and a nginx process start instruction respectively.

[0127] Optionally, the confirmation module 302 is specifically configured to:

[0128] According to the process query instruction, confirm the nginx process in the running state in itself as the process to be recognized, and obtain the identification information of the process to be recognized.

[0129] Optionally, the device further includes: a start saving module, configured to:

[0130] Receive a process start instruction issued by the user, start the corresponding process according to the process start instruction, and save the process start instruction.

[0131] From Figure 3 As can be seen from the embodiments shown, when the paths of the executable file and the configuration file in the process start instruction of the process to be recognized are both relative paths, by using the device provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained, and then, according to the absolute paths of the executable file and the configuration file of the process, a process in the running state can be uniquely determined. That is to say, the device provided by the embodiments of the present invention can achieve accurate recognition of the process, and further can achieve accurate control of the process. In summary, the device provided by the embodiments of the present invention can solve the problem in the prior art that accurate recognition and control of the process cannot be achieved.

[0132] Corresponding to Figure 1 the embodiments shown, an embodiment of the present invention further provides an electronic device. Refer to Figure 4 , including a processor 401, a communication interface 402, a memory 403, and a communication bus 404. Among them, the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404;

[0133] The memory 403 is used to store a computer program;

[0134] When the processor 401 is used to execute the program stored on the memory, it implements the method steps of any of the above-mentioned process recognition embodiments.

[0135] When the paths of the executable file and the configuration file in the process start instruction of the process to be recognized are both relative paths, by using the electronic device provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained, and then, according to the absolute paths of the executable file and the configuration file of the process, a process in the running state can be uniquely determined. That is to say, the electronic device provided by the embodiments of the present invention can achieve accurate recognition of the process, and further can achieve accurate control of the process. In summary, the electronic device provided by the embodiments of the present invention can solve the problem in the prior art that accurate recognition and control of the process cannot be achieved.

[0136] Corresponding to Figure 1Corresponding to the illustrated embodiments, embodiments of the present invention further provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any process recognition in the above embodiments are implemented.

[0137] When the paths of both the executable file and the configuration file are relative paths in the process startup instruction of the process to be recognized, by using the storage medium provided by the embodiments of the present invention, the absolute path of the configuration file can still be obtained. Then, a process in the running state can be uniquely determined according to the absolute paths of the executable file and the configuration file of the process. That is to say, the storage medium provided by the embodiments of the present invention can achieve accurate recognition of the process, and further can achieve accurate control of the process. In summary, the storage medium provided by the embodiments of the present invention can solve the problem in the prior art that accurate recognition and control of the process cannot be achieved.

[0138] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0139] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of flows and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0140] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the functions specified in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0141] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions for implementing the steps specified in one process or multiple processes and / or blocks Figure 1 one process or multiple processes and / or blocks Figure 1 steps for the functions specified in one block or multiple blocks.

[0142] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these changes and modifications.

Claims

1. A method for process identification, characterized in that, Applied to a virtual machine or a hardware server, including the following steps: Receiving a process query instruction and an instruction for obtaining a process start instruction respectively; wherein, the process start instruction is an instruction input when starting a process; According to the process query instruction, identifying the processes in the running state in itself as processes to be identified, and obtaining the identification information of the processes to be identified; the processes to be identified are processes to be identified of nginx, and the directory where the nginx process is located is added to the PATH environment variable; According to the instruction for obtaining the process start instruction, obtaining the process start instruction of the process to be identified; wherein, the process start instruction of the process to be identified includes: the start instruction of the executable file corresponding to the process to be identified, the start instruction of the configuration file corresponding to the process to be identified; the start instruction of the executable file contains the path of the executable file; the start instruction of the configuration file contains the path of the configuration file; Obtaining the paths of the executable file and the configuration file corresponding to the process to be identified from the process start instruction of the process to be identified; When the paths of the executable file and the configuration file obtained from the process start instruction of the process to be identified are both relative paths, obtaining the absolute path of the executable file corresponding to the process to be identified from the virtual file system according to the identification information of the process to be identified; Matching the absolute path of the executable file corresponding to the process to be identified with the relative path of the executable file corresponding to the process to be identified to determine the current directory of the relative path of the executable file; wherein, matching the string of the absolute path of the executable file corresponding to the process to be identified with the string of the relative path of the executable file corresponding to the process to be identified to determine the current directory of the relative path of the executable file; Determining the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file; Determining the absolute path of the configuration file corresponding to the process to be identified according to the upper-level directory of the relative path of the executable file; Identifying the process to be identified according to the absolute paths of the executable file and the configuration file corresponding to the process to be identified.

2. The method according to claim 1, characterized in that, The method further includes: When the paths of the executable file and the configuration file in the process start instruction of the process to be identified are absolute paths, obtaining the absolute paths of the executable file and the configuration file, and identifying the process to be identified according to the absolute paths of the executable file and the configuration file.

3. The method according to claim 1, wherein The step of receiving a process query instruction and an instruction for obtaining a process start instruction respectively includes: Receiving a process query instruction and an instruction for obtaining an nginx process start instruction respectively.

4. The method according to claim 3, wherein The step of, according to the process query instruction, identifying the processes in the running state in itself as processes to be identified, and obtaining the identification information of the processes to be identified includes: According to the process query instruction, identifying the running nginx processes in itself as processes to be identified, and obtaining the identification information of the processes to be identified.

5. The method according to claim 1, wherein Before the step of obtaining the process start instruction of the to-be-identified process according to the instruction for obtaining the process start instruction, the following steps are further included: Receive the process start instruction issued by the user, start the corresponding process according to the process start instruction, and save the process start instruction.

6. A device for process identification, characterized in that, The device includes: An instruction receiving module, configured to receive a process query instruction and an instruction for obtaining a process start instruction respectively; wherein, the process start instruction is an instruction input when starting a process; A confirmation module, configured to confirm the processes in its own running state as to-be-identified processes according to the process query instruction, and obtain the identification information of the to-be-identified processes; the to-be-identified processes are to-be-identified nginx processes, and the directory where the nginx processes are located is added to the PATH environment variable; An instruction obtaining module, configured to obtain the process start instruction of the to-be-identified process according to the instruction for obtaining the process start instruction; wherein, the process start instruction of the to-be-identified process includes: the start instruction of the executable file corresponding to the to-be-identified process, the start instruction of the configuration file corresponding to the to-be-identified process; the start instruction of the executable file contains the path of the executable file; the start instruction of the configuration file contains the path of the configuration file; A path obtaining module, configured to obtain the paths of the executable file and the configuration file corresponding to the to-be-identified process from the process start instruction of the to-be-identified process; An obtaining module, configured to, when the paths of the executable file and the configuration file obtained from the process start instruction of the to-be-identified process are both relative paths, obtain the absolute path of the executable file corresponding to the to-be-identified process from the virtual file system according to the identification information of the to-be-identified process; A matching module, configured to match the absolute path of the executable file corresponding to the to-be-identified process with the relative path of the executable file corresponding to the to-be-identified process to determine the current directory of the relative path of the executable file; wherein, match the string of the absolute path of the executable file corresponding to the to-be-identified process with the string of the relative path of the executable file corresponding to the to-be-identified process to determine the current directory of the relative path of the executable file; A first determination module, configured to determine the upper-level directory of the relative path of the executable file according to the current directory of the relative path of the executable file; A second determination module, configured to determine the absolute path of the configuration file corresponding to the to-be-identified process according to the upper-level directory of the relative path of the executable file; An identification module, configured to identify the to-be-identified process according to the absolute paths of the executable file and the configuration file corresponding to the to-be-identified process.

7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory and a communication bus. Among them, the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used to store a computer program; When the processor executes the program stored on the memory, it implements the method steps of any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1-5 are implemented.

Citation Information

Patent Citations

  • Method, device and equipment for managing and controlling processes in container and readable storage medium

    CN114237924A