Skip to content

KillProcess

Narta Xaymar Dirks edited this page Dec 3, 2026 · 2 revisions

KillProcess BlitzLLVM

KillProcess:Void process:Int32, force:Int32=0
Parameter Mode Type Default Description
process In Int32 required The stream that CreateProcess returned.
force In Int32 0 1 to end the program without letting it react (SIGKILL), 0 to ask it (SIGTERM). Only makes a difference on Linux and macOS. Defaults to 0.

Description

BlitzLLVM This command does not exist in the original Blitz products. BlitzLLVM adds it.

Ends a program started with CreateProcess. This is a BlitzLLVM extension: the originals can't end the program once it is started, and closing its stream only closes the pipes to it.

  • On Linux and macOS the program gets SIGTERM, which it can handle to save and end on its own; it may take a moment to end, so use WaitProcess to wait for it. With force it gets SIGKILL, which it can't refuse.
  • On Windows a program without a console has no polite way to be asked, so it is ended at once, with or without force, and has no chance to save. It ends with the exit code 143 (137 with force), the same that ProcessExitCode gives on the other systems.
  • To let a program save first, ask it to end in a way it understands (for example a line written to its stream), wait for it with WaitProcess and a timeout, and only end it if it doesn't.
  • Nothing happens when the program has already ended.
  • Only the program itself is ended. When the command was more than one program (with ;, && or | on Linux and macOS), it is the shell that runs them that gets the signal.
  • The stream stays open: what the program wrote before it ended can still be read, and it still has to be closed with CloseFile.

Examples

server = CreateProcess("StrandedII -server")
; ... the game ...
WriteLine server, "quit"
If Not WaitProcess(server, 5000) Then KillProcess server
CloseFile server

Related Commands

CreateProcess BlitzPlus, ProcessExitCode BlitzLLVM, ProcessID BlitzLLVM, ProcessRunning BlitzLLVM, ReadProcessStream BlitzLLVM, WaitProcess BlitzLLVM, WriteProcessStream BlitzLLVM

Home · Command Index


Getting started

Language

Tools


Language Features
BlitzBasic
Blitz3D
BlitzPlus
Differences

More

Clone this wiki locally