% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/optimize_model.R
\name{cleanup_parallel_workers}
\alias{cleanup_parallel_workers}
\title{Clean up orphaned parallel worker processes}
\usage{
cleanup_parallel_workers(signal = "TERM", verbose = TRUE, list_only = FALSE)
}
\arguments{
\item{signal}{Signal to send (default "TERM" for graceful shutdown, use "KILL" for force)}

\item{verbose}{Whether to print messages (default TRUE)}

\item{list_only}{If TRUE, only list potential workers without killing them (default FALSE)}
}
\value{
Invisible NULL (or vector of PIDs if list_only = TRUE)
}
\description{
When using parallel estimation with Ctrl-C interrupts, worker processes may
continue running after the main process exits. This function finds and
terminates any orphaned R worker processes started by the parallel package.
}
\examples{
# Safe to run: list potential orphaned parallel workers without killing them.
cleanup_parallel_workers(list_only = TRUE, verbose = FALSE)

\donttest{
# After interrupting a parallel job with Ctrl-C, terminate orphaned workers:
cleanup_parallel_workers()

# Force kill if graceful shutdown doesn't work:
cleanup_parallel_workers(signal = "KILL")
}
}
