Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1572234
  • 博文数量: 596
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 173
  • 用 户 组: 普通用户
  • 注册时间: 2016-07-06 15:50
个人简介

在线笔记

文章分类

全部博文(596)

文章存档

2016年(1)

2015年(104)

2014年(228)

2013年(226)

2012年(26)

2011年(11)

分类: Windows平台

2014-06-17 15:40:47


  1. Terminating a process has the following results:

  2.     Any remaining threads in the process are marked for termination.
  3.     Any resources allocated by the process are freed.
  4.     All kernel objects are closed.
  5.     The process code is removed from memory.
  6.     The process exit code is set.
  7.     The process object is signaled.

  8. While open handles to kernel objects are closed automatically when a process terminates, the objects themselves exist until all open handles to them are closed. Therefore, an object will remain valid after a process that is using it terminates if another process has an open handle to it.()

  9. The GetExitCodeProcess function returns the termination status of a process. While a process is executing, its termination status is STILL_ACTIVE. When a process terminates, its termination status changes from STILL_ACTIVE to the exit code of the process.GetExitCodeProcess返回进程的终止状态。进程运行时,终止状态是STILL_ACTIVE,终止时为进程的退出码)

  10. When a process terminates, the state of the process object becomes signaled, releasing any threads that had been waiting for the process to terminate. For more about synchronization, see Synchronizing Execution of Multiple Threads.(进程终止时,进程对象句柄会收到signal,其他线程可以监听该信号。)

  11. When the system is terminating a process, it does not terminate any child processes that the process has created. Terminating a process does not generate notifications for WH_CBT hook procedures.(系统终止进程时,不会终止其子进程。)

  12. Use the SetProcessShutdownParameters function to specify certain aspects of the process termination at system shutdown, such as when a process should terminate relative to the other processes in the system.SetProcessShutdownParameters设置系统关机时,可以杀死其他进程)
  13. How Processes are Terminated

  14. A process executes until one of the following events occurs:

  15.     1)Any thread of the process calls the ExitProcess function. Note that some implementation of the C run-time library (CRT) call ExitProcess if the primary thread of the process returns.(进程的任意一个线程调用ExitProcess。NOTE:某些CRT在主线程退出时调用ExitProcess)
  16.     2)The last thread of the process terminates.(进程的最后一个线程退出)
  17.     3)Any thread calls the TerminateProcess function with a handle to the process.(任意线程(进程自身或其他进程),调用TerminateProcess
  18.     4)For console processes, the default console control handler calls ExitProcess when the console receives a CTRL+C or CTRL+BREAK signal.(控制台接收到CTRL+C or CTRL+BREAK信号,调用ExitProcess
  19.     5)The user shuts down the system or logs off.(用户关机或注销)

  20. Do not terminate a process unless its threads are in known states. If a thread is waiting on a kernel object, it will not be terminated until the wait has completed. This can cause the application to stop responding.(如果线程等待内核对象,导致线程不会被杀死,直到等待结束)

  21. The primary thread can avoid terminating other threads by directing them to call ExitThread before causing the process to terminate (for more information, see Terminating a Thread). The primary thread can still call ExitProcess afterwards to ensure that all threads are terminated.(主线程调用ExitProcess保证所有线程终止)

  22. The exit code for a process is either the value specified in the call to ExitProcess or TerminateProcess, or the value returned by the main or WinMain function of the process. If a process is terminated due to a fatal exception, the exit code is the value of the exception that caused the termination. In addition, this value is used as the exit code for all the threads that were executing when the exception occurred.(返回码可以是ExitProcessTerminateProcess所设定的,可以是main函数返回的,也可以是导致进程异常终止的退出码)

  23. If a process is terminated by ExitProcess, the system calls the entry-point function of each attached DLL with a value indicating that the process is detaching from the DLL. DLLs are not notified when a process is terminated by TerminateProcess. For more information about DLLs, see Dynamic-Link Libraries.ExitProcess通知进程的DLL进程退出,TerminateProcess不做此通知)

  24. If a process is terminated by TerminateProcess, all threads of the process are terminated immediately with no chance to run additional code. This means that the thread does not execute code in termination handler blocks. In addition, no attached DLLs are notified that the process is detaching. If you need to have one process terminate another process, the following steps provide a better solution:TerminateProcess会立即终止进程,进程没有时间做其他事情。)

  25.     Have both processes call the RegisterWindowMessage function to create a private message.
  26.     One process can terminate the other process by broadcasting a private message using the BroadcastSystemMessage function as follows:

  27.         DWORD dwRecipients = BSM_APPLICATIONS;
  28.         UINT uMessage = PM_MYMSG;
  29.         WPARAM wParam = 0;
  30.         LPARAM lParam = 0;

  31.         BroadcastSystemMessage(
  32.             BSF_IGNORECURRENTTASK, // do not send message to this process
  33.             &dwRecipients, // broadcast only to applications
  34.             uMessage, // registered private message
  35.             wParam, // message-specific value
  36.             lParam ); // message-specific value

  37.     The process receiving the private message calls ExitProcess to terminate its execution.

  38. The execution of the ExitProcess, ExitThread, CreateThread, CreateRemoteThread, and CreateProcess functions is serialized within an address space. The following restrictions apply:

  39.     During process startup and DLL initialization routines, new threads can be created, but they do not begin execution until DLL initialization is finished for the process.
  40.     Only one thread at a time can be in a DLL initialization or detach routine.
  41.     The ExitProcess function does not return until there are no threads are in their DLL initialization or detach routines.

阅读(557) | 评论(0) | 转发(0) |
0

上一篇:windows关机,窗口事件

下一篇:find exec linux

给主人留下些什么吧!~~