如何安全地杀死 robocopy 进程
How to safely kill robocopy process
我有一个 win32 应用程序,我正在为一些文件传输启动一个 robocopy 子进程。如果我使用 TerminateProcess 终止进程,是否有可能以损坏的文件结束?如果是这样如何避免这种情况?
来自TerminateProcess函数,
The TerminateProcess function is used to unconditionally cause a
process to exit. The state of global data maintained by dynamic-link
libraries (DLLs) may be compromised if TerminateProcess is used rather
than ExitProcess.
请记住,TerminateProcess
不允许其目标以有效状态清理和退出。
尝试干净地关闭进程,参考下面的link,
- How To Terminate an Application "Cleanly" in Win32
如果 robocopy 进程终止,正在复制的文件将具有 (a) 1980-01-01 (b) 与原始文件相同大小的时间戳。
然后在命令行中使用robocopy再次复制带有TimeStamp的文件
参考:
我有一个 win32 应用程序,我正在为一些文件传输启动一个 robocopy 子进程。如果我使用 TerminateProcess 终止进程,是否有可能以损坏的文件结束?如果是这样如何避免这种情况?
来自TerminateProcess函数,
The TerminateProcess function is used to unconditionally cause a process to exit. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
请记住,TerminateProcess
不允许其目标以有效状态清理和退出。
尝试干净地关闭进程,参考下面的link,
- How To Terminate an Application "Cleanly" in Win32
如果 robocopy 进程终止,正在复制的文件将具有 (a) 1980-01-01 (b) 与原始文件相同大小的时间戳。
然后在命令行中使用robocopy再次复制带有TimeStamp的文件
参考: