Skip to content

Commit 4040547

Browse files
Merge pull request #167 from davemungo/DOCSP-16154-graceful-handling-of-ctrl-c
DOCSP-16154 Graceful handling of ctrl+c
2 parents 6b0a23b + 7ed1d27 commit 4040547

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

source/run-commands.txt

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,30 @@ using the :option:`--norc <mongosh --norc>` option.
117117
Terminate a Running Command
118118
---------------------------
119119

120-
To terminate a running command or query in ``mongosh``,
120+
To terminate a running command or query in :binary:`~bin.mongosh`,
121121
press ``Ctrl + C``.
122122

123-
``Ctrl + C`` terminates the process in the shell, but does not
124-
terminate the process on the MongoDB server. This behavior
125-
differs from the :method:`db.killOp()` method, which terminates
126-
commands on the server.
123+
When you enter ``Ctrl + C``, :binary:`~bin.mongosh`:
124+
125+
- interrupts the active command,
126+
- tries to terminate the ongoing, server-side operation, and
127+
- returns a command prompt.
128+
129+
If :binary:`~bin.mongosh` cannot cleanly terminate the running process,
130+
it issues a warning.
131+
132+
.. note::
133+
134+
Pressing ``Ctrl + C`` in :binary:`~bin.mongosh` does not terminate
135+
asynchronous code. Asynchronous operations such as ``setTimeout`` or
136+
operations like ``fs.readFile`` continue to run.
137+
138+
There is no way to terminate asynchronous code in
139+
:binary:`~bin.mongosh`. This is the same behavior as in the Node.js
140+
`REPL <https://nodejs.org/api/repl.html>`__.
141+
142+
Pressing ``Ctrl + C`` once will not exit :binary:`~bin.mongosh`, press
143+
``Ctrl + C`` twice to exit :binary:`~bin.mongosh`.
127144

128145
Command Exceptions
129146
------------------
@@ -150,3 +167,4 @@ with ``Ctrl + L`` and ``console.clear()``.
150167

151168
/crud
152169
/run-agg-pipelines
170+

0 commit comments

Comments
 (0)