MCPcopy Index your code
hub / github.com/Sandpack/nodebox-runtime / kill

Method kill

packages/nodebox/src/modules/shell.ts:130–151  ·  view source on GitHub ↗

* Terminates the shell process.

()

Source from the content-addressed store, hash-verified

128 * Terminates the shell process.
129 */
130 public async kill(): Promise<void> {
131 invariant(
132 this.id,
133 'Failed to run "kill" on a ShellProcess: there is no process running. Did you forget to run it?'
134 );
135
136 /**
137 * @note Optimistically (and eagerly) transition the shell to the next state.
138 * Shell exit only fails on protocol mismatch or when it's already been killed.
139 */
140 this.state = 'idle';
141
142 /**
143 * @todo I wonder if we should support a custom "exitCode" here
144 * or a signal.
145 */
146 await this.channel.send('shell/exit', { id: this.id }).catch((error) => {
147 throw new Error(format('Failed to kill shell with ID "%s"', this.id), { cause: error });
148 });
149
150 this.id = undefined;
151 }
152}

Callers 4

globalSetupFunction · 0.80
spawnAndWaitForStdoutFunction · 0.80
stopPreviewFunction · 0.80

Calls 1

sendMethod · 0.45

Tested by 1

stopPreviewFunction · 0.64