Job Control

Job control allows managing multiple processes from a single shell session.

Source: src/execution/jobs.f90, src/execution/builtins.f90, src/system/signal_handling.f90

Overview

fortsh provides full job control capabilities:

Quick Reference

Background Operations

command &           # Run in background
jobs                # List jobs
fg %n               # Bring job to foreground
bg %n               # Resume job in background
Ctrl+Z              # Suspend foreground job

Job Specification

SyntaxMeaning
%nJob number n
%% or %+Current job
%-Previous job
%?stringJob containing string

Signal Operations

kill %n             # Send SIGTERM to job
kill -9 %n          # Send SIGKILL to job
kill -l             # List signals
trap 'cmd' SIGNAL   # Set signal handler

Job States

StateDescription
RunningActively executing
StoppedSuspended (Ctrl+Z or SIGTSTP)
DoneCompleted execution

Common Patterns

Background Long Tasks

find / -name "*.log" > logs.txt &
# Continue with other work...
jobs
fg %1              # Check on it when ready

Suspend and Resume

vim file.txt
# Press Ctrl+Z to suspend
jobs               # [1]+ Stopped vim file.txt
fg %1              # Resume editing

Multiple Background Jobs

./download1.sh &
./download2.sh &
./download3.sh &
jobs
wait               # Wait for all to complete