#5061·steampipe

BUG: service stop --force leaves Postgres running when one process's command line can't be read

Author: kaidaguerreCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbug

Description

steampipe service stop --force can leave the Postgres service running while reporting success, and delete the service's running-info file. The next steampipe service start then fails with:

Error: service is running in an unknown state [PID: NNNN] - try killing it with steampipe service stop --force

FindAllSteampipePostgresInstances walks every process on the machine and returns an error for the whole scan if it cannot read any single process's command line — for example because that process exited during the scan. killInstanceIfAny treats that error as "no instances", so stopDBService(force=true) returns ServiceNotRunning with no error, and StopServices then removes the running-info file while Postgres keeps running.

Severity

MEDIUM - service stop --force is the documented recovery path, and it silently does nothing; the service is then left in the "unknown state" it tells the user to fix with the same command.

Reproduction

Intermittent; more likely on a machine with many short-lived processes (a typical developer Mac). Seen in tests/acceptance/test_files/ssl.bats on macOS:

  1. steampipe service start, then steampipe service restart
  2. steampipe service stop --force — trace log shows FindAllSteampipePostgresInstances - error retrieving cmdline for pid NNNN: exit status 1, then stopped DB Service; Postgres is not signalled
  3. steampipe service start fails with "service is running in an unknown state"

Expected Behavior

A process whose command line cannot be read is skipped, and the scan still finds and stops the steampipe Postgres instances.

Current Behavior

The whole scan fails, nothing is stopped, and the running-info file is deleted.

Suggested Fix

Log and skip the unreadable process instead of returning, as killRunningDbInstance in pkg/db/db_local/backup.go already does for the same error.

Related Code

  • pkg/db/db_local/start_services.go - FindAllSteampipePostgresInstances returns on the first CmdlineSliceWithContext error
  • pkg/db/db_local/start_services.go - killInstanceIfAny treats the error as "nothing running"
  • pkg/db/db_local/stop_services.go - StopServices removes the running-info file when stopDBService returns no error
  • Also affects steampipe service status --all (cmd/service.go, showAllStatus) and killRunningDbInstance (pkg/db/db_local/backup.go)