Terminating a Process
来源:互联网 发布:数据库中记录不得重复 编辑:程序博客网 时间:2024/05/18 15:30
- Terminating a process has the following results:
- Any remaining threads in the process are marked for termination.
- Any resources allocated by the process are freed.
- All kernel objects are closed.
- The process code is removed from memory.
- The process exit code is set.
- The process object is signaled.
- 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.()
- 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,终止时为进程的退出码)
- 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,其他线程可以监听该信号。)
- 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.(系统终止进程时,不会终止其子进程。)
- 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设置系统关机时,可以杀死其他进程)
- How Processes are Terminated
- A process executes until one of the following events occurs:
- 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)
- 2)The last thread of the process terminates.(进程的最后一个线程退出)
- 3)Any thread calls the TerminateProcess function with a handle to the process.(任意线程(进程自身或其他进程),调用TerminateProcess)
- 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)
- 5)The user shuts down the system or logs off.(用户关机或注销)
- 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.(如果线程等待内核对象,导致线程不会被杀死,直到等待结束)
- 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保证所有线程终止)
- 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.(返回码可以是ExitProcess或TerminateProcess所设定的,可以是main函数返回的,也可以是导致进程异常终止的退出码)
- 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不做此通知)
- 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会立即终止进程,进程没有时间做其他事情。)
- Have both processes call the RegisterWindowMessage function to create a private message.
- One process can terminate the other process by broadcasting a private message using the BroadcastSystemMessage function as follows:
- DWORD dwRecipients = BSM_APPLICATIONS;
- UINT uMessage = PM_MYMSG;
- WPARAM wParam = 0;
- LPARAM lParam = 0;
- BroadcastSystemMessage(
- BSF_IGNORECURRENTTASK, // do not send message to this process
- &dwRecipients, // broadcast only to applications
- uMessage, // registered private message
- wParam, // message-specific value
- lParam ); // message-specific value
- The process receiving the private message calls ExitProcess to terminate its execution.
- The execution of the ExitProcess, ExitThread, CreateThread, CreateRemoteThread, and CreateProcess functions is serialized within an address space. The following restrictions apply:
- 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.
- Only one thread at a time can be in a DLL initialization or detach routine.
- The ExitProcess function does not return until there are no threads are in their DLL initialization or detach routines.
0
上一篇:windows关机,窗口事件
下一篇:find exec linux
相关热门文章
- LNK1123: 转换到 COFF 期间失...
- WIN7访问共享:0x80070035 找不...
- Delphi 2010下载+完美破解...
- vs2010调试C++程序时提示 无...
- VISIO,不规则封闭图形填充方...
- linux dhcp peizhi roc
- 关于Unix文件的软链接
- 求教这个命令什么意思,我是新...
- sed -e "/grep/d" 是什么意思...
- 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
评论热议
0 0
- Terminating a Process
- howto prevent a process from terminating when writing to a broken pipe
- TCP: terminating a connection 3
- fork a process
- Linux kill a process
- A Task Process DP
- How a process created
- what is a process?
- Debugging a Running Process
- a process hosting a service
- Starting a process from KernelMode
- Starting a process from KernelMode
- Starting a Process from KernelMode
- How to spawn a process
- hdu 3433 A Task Process
- A Task Process hdu 3433
- test process for a project
- HDU 3433 A Task Process
- hjr学习-设计模式:工厂模式
- ubuntu按照perl模块
- windows 的关机,睡眠,休眠
- windows关机,窗口事件
- collectd安装redis插件
- Terminating a Process
- find exec linux
- POJ 1050 To the Max
- Spring Bean的生命周期(非常详细)
- windows 事件小结
- c++ map 测试
- 通过视图进行数据绑定
- Key usage violation in certificate has been detected
- 《中国新歌声》81位评审为何投出92票
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
三角形和星形接法图实物图
星露谷物语潘妮爬树图
星图563422寇w
星角启动实物接线图
迷你星工厂图纸花小楼
艺星开眼角前后对比图
广州品秀星图
星图注册
星图下载
星图怎么用
星图破解版
三角形接法和星形接法图
星圣卡组
战星圣魔 神也发愁
星坐
星坐查询
星坐的月份
星坐是怎么划分的
梦想星城
悦居星城
卫星城
水岸星城
世家星城
悦居星城app
东晖星城
世纪星城
日月星城
福地星城
新世纪星城
龙源星城
摄山星城
传媒星城
百合星城
滇池星城
天源星城
锦绣星城
星城在线
万达星城
奥林星城
冠亚星城
学府星城