Home

Setsid

Setsid is a Unix utility that runs a program in a new session, thereby detaching it from the current controlling terminal and from the current process group. It is commonly used to start long-running tasks in the background, such as daemons, without being affected by terminal hangups or job control from the launching shell.

Technical overview: When invoked with a command, setsid forks a child process that creates a new session,

Usage: The typical syntax is setsid [PROGRAM [ARG]...]. If a program is provided, it is started in

Common use cases: daemonizing a process, starting background jobs from scripts, or ensuring that a command does

See also: nohup, disown, daemon, session, process group.

becomes
the
session
leader
of
that
session,
and
disassociates
from
any
controlling
terminal.
The
specified
program
is
then
executed
inside
this
new
session.
The
effect
is
that
the
started
process
runs
in
isolation
from
the
terminal
that
launched
it,
reducing
the
chance
that
terminal
actions
will
signal
or
interfere
with
it.
the
new
session;
if
not,
behavior
can
vary
by
implementation.
In
practice,
users
employ
setsid
to
launch
services
or
commands
that
should
keep
running
independently
of
the
initiating
shell
or
terminal.
not
receive
terminal-related
signals
when
the
terminal
is
closed.
Setsid
is
often
used
in
combination
with
other
tools
such
as
nohup
or
disown
to
further
detach
a
process
from
terminals
and
sessions.