Skip to content

Commit aafba2c

Browse files
wtgodbeRon Petrusha
authored andcommitted
Add documentation for Process.Kill(bool entireProcessTree) (#2828)
* Add documentation for Process.Kill(bool entireProcessTree) * Update Process.xml * minor fix: parm summary in single line * Address feedback * Address Feedback * Fixed bad xml element
1 parent b2ed49e commit aafba2c

File tree

1 file changed

+70
-28
lines changed

1 file changed

+70
-28
lines changed

xml/System.Diagnostics/Process.xml

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ process.BeginOutputReadLine();
705705
<format type="text/markdown"><![CDATA[
706706

707707
## Remarks
708-
When a process is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close to the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
708+
When a process is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
709709

710710
Data edited by the process or resources allocated to the process can be lost if you call <xref:System.Diagnostics.Process.Kill%2A>. <xref:System.Diagnostics.Process.Kill%2A> causes an abnormal process termination, and should be used only when necessary. <xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface. If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use <xref:System.Diagnostics.Process.Kill%2A> to terminate the process. <xref:System.Diagnostics.Process.Kill%2A> is the only way to terminate processes that do not have graphical interfaces.
711711

@@ -2054,6 +2054,49 @@ There are problems accessing the performance counter API's used to get process i
20542054
<altmember cref="M:System.Diagnostics.Process.GetProcessById(System.Int32,System.String)" />
20552055
</Docs>
20562056
</Member>
2057+
<MemberGroup MemberName="Kill">
2058+
<Docs>
2059+
<summary>To be added.</summary>
2060+
<remarks>
2061+
<format type="text/markdown"><![CDATA[
2062+
2063+
## Remarks
2064+
2065+
The `Kill` method forces a termination of the process, while <xref:System.Diagnostics.Process.CloseMainWindow%2A> only requests a termination.
2066+
When a process with a graphical interface is executing, its message loop is in a wait state.
2067+
The message loop executes every time a Windows message is sent to the process by the operating system.
2068+
Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application.
2069+
The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit.
2070+
The application can ask for user verification before quitting, or it can refuse to quit.
2071+
To force the application to quit, use the `Kill` method.
2072+
2073+
The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu.
2074+
Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
2075+
2076+
> [!NOTE]
2077+
> The <xref:System.Diagnostics.Process.Kill%2A> method executes asynchronously.
2078+
> After calling the `Kill` method, call the <xref:System.Diagnostics.Process.WaitForExit%2A> method to wait for the process to exit, or check the <xref:System.Diagnostics.Process.HasExited%2A> property to determine if the process has exited.
2079+
2080+
> [!NOTE]
2081+
> The <xref:System.Diagnostics.Process.WaitForExit%2A> method and the <xref:System.Diagnostics.Process.HasExited%2A> property do not reflect the status of descendant processes.
2082+
> When `Kill(entireProcessTree: true)` is used, <xref:System.Diagnostics.Process.WaitForExit%2A> and <xref:System.Diagnostics.Process.HasExited%2A> will indicate that exiting has completed after the given process exits, even if all descendants have not yet exited.
2083+
2084+
Data edited by the process or resources allocated to the process can be lost if you call `Kill`.
2085+
`Kill` causes an abnormal process termination and should be used only when necessary.
2086+
<xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface.
2087+
If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use `Kill` to terminate the process.
2088+
`Kill` is the only way to terminate processes that do not have graphical interfaces.
2089+
2090+
You can call `Kill` and <xref:System.Diagnostics.Process.CloseMainWindow%2A> only for processes that are running on the local computer.
2091+
You cannot cause processes on remote computers to exit. You can only view information for processes running on remote computers.
2092+
2093+
> [!NOTE]
2094+
> If the call to the `Kill` method is made while the process is currently terminating, a <xref:System.ComponentModel.Win32Exception> is thrown for Access Denied.
2095+
2096+
]]></format>
2097+
</remarks>
2098+
</Docs>
2099+
</MemberGroup>
20572100
<Member MemberName="Kill">
20582101
<MemberSignature Language="C#" Value="public void Kill ();" />
20592102
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Kill() cil managed" />
@@ -2086,33 +2129,12 @@ There are problems accessing the performance counter API's used to get process i
20862129
<Parameters />
20872130
<Docs>
20882131
<summary>Immediately stops the associated process.</summary>
2089-
<remarks>
2090-
<format type="text/markdown"><![CDATA[
2091-
2092-
## Remarks
2093-
<xref:System.Diagnostics.Process.Kill%2A> forces a termination of the process, while <xref:System.Diagnostics.Process.CloseMainWindow%2A> only requests a termination. When a process with a graphical interface is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close to the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
2094-
2095-
> [!NOTE]
2096-
> The <xref:System.Diagnostics.Process.Kill%2A> method executes asynchronously. After calling the <xref:System.Diagnostics.Process.Kill%2A> method, call the <xref:System.Diagnostics.Process.WaitForExit%2A> method to wait for the process to exit, or check the <xref:System.Diagnostics.Process.HasExited%2A> property to determine if the process has exited.
2097-
2098-
Data edited by the process or resources allocated to the process can be lost if you call <xref:System.Diagnostics.Process.Kill%2A>. <xref:System.Diagnostics.Process.Kill%2A> causes an abnormal process termination and should be used only when necessary. <xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface. If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use <xref:System.Diagnostics.Process.Kill%2A> to terminate the process. <xref:System.Diagnostics.Process.Kill%2A> is the only way to terminate processes that do not have graphical interfaces.
2099-
2100-
You can call <xref:System.Diagnostics.Process.Kill%2A> and <xref:System.Diagnostics.Process.CloseMainWindow%2A> only for processes that are running on the local computer. You cannot cause processes on remote computers to exit. You can only view information for processes running on remote computers.
2101-
2102-
> [!NOTE]
2103-
> If the call to the <xref:System.Diagnostics.Process.Kill%2A> method is made while the process is currently terminating, a <xref:System.ComponentModel.Win32Exception> is thrown for Access Denied.
2104-
2105-
]]></format>
2106-
</remarks>
2132+
<remarks>To be added.</remarks>
21072133
<exception cref="T:System.ComponentModel.Win32Exception">The associated process could not be terminated.
21082134

21092135
-or-
21102136

2111-
The process is terminating.
2112-
2113-
-or-
2114-
2115-
The associated process is a Win16 executable.</exception>
2137+
The process is terminating.</exception>
21162138
<exception cref="T:System.NotSupportedException">You are attempting to call <see cref="M:System.Diagnostics.Process.Kill" /> for a process that is running on a remote computer. The method is available only for processes running on the local computer.</exception>
21172139
<exception cref="T:System.InvalidOperationException">The process has already exited.
21182140

@@ -2150,9 +2172,29 @@ There are problems accessing the performance counter API's used to get process i
21502172
<Parameter Name="entireProcessTree" Type="System.Boolean" Index="0" FrameworkAlternate="netcore-3.0" />
21512173
</Parameters>
21522174
<Docs>
2153-
<param name="entireProcessTree">To be added.</param>
2154-
<summary>To be added.</summary>
2155-
<remarks>To be added.</remarks>
2175+
<param name="entireProcessTree"><see langword="true" /> to kill the associated process and its descendants; <see langword="false" /> to kill only the associated process.</param>
2176+
<summary>Immediately stops the associated process, and optionally its child/descendent processes.</summary>
2177+
<remarks>When <paramref name="entireProcessTree" /> is set to <see langword="true" />, processes where the call lacks permissions to view details are silently skipped by the descendant termination process because the termination process is unable to determine whether those processes are descendants.</remarks>
2178+
<exception cref="T:System.ComponentModel.Win32Exception">The associated process could not be terminated.
2179+
2180+
-or-
2181+
2182+
The process is terminating.</exception>
2183+
<exception cref="T:System.NotSupportedException">You are attempting to call <see cref="M:System.Diagnostics.Process.Kill" /> for a process that is running on a remote computer. The method is available only for processes running on the local computer.</exception>
2184+
<exception cref="T:System.InvalidOperationException">The process has already exited.
2185+
2186+
-or-
2187+
2188+
There is no process associated with this <see cref="T:System.Diagnostics.Process" /> object.
2189+
2190+
-or-
2191+
2192+
The calling process is a member of the associated process' descendant tree.</exception>
2193+
<exception cref="T:System.AggregateException">Not all processes in the associated process' descendant tree could be terminated.</exception>
2194+
<permission cref="F:System.Security.Permissions.SecurityAction.LinkDemand">for full trust for the immediate caller. This member cannot be used by partially trusted code.</permission>
2195+
<altmember cref="M:System.Environment.Exit(System.Int32)" />
2196+
<altmember cref="M:System.Diagnostics.Process.CloseMainWindow" />
2197+
<altmember cref="M:System.Diagnostics.Process.Start" />
21562198
</Docs>
21572199
</Member>
21582200
<Member MemberName="LeaveDebugMode">
@@ -6213,4 +6255,4 @@ There is a similar issue when you read all text from both the standard output an
62136255
</Docs>
62146256
</Member>
62156257
</Members>
6216-
</Type>
6258+
</Type>

0 commit comments

Comments
 (0)