Is it possible and if so how do I:
- Start a
/bin/bash
process that is not bound to a terminal from a terminal? Hence, a shell process that shows up in the process tree asinit -- bash
. (Shells usually have the process tree structureterminal-emulator-of-your-choosing -- bash
) - Start a
/bin/bash
process not bound to a terminal that has as its child another process e.g. a browser likefirefox
from a shell session in a terminal? Hence, a shell process with a child that shows up in the process tree asinit -- bash -- firefox
. - It is easy to get
init -- firefox
directly from the shell via something along the lines ofexec firefox & exit
or/bin/bash -c firefox & exit
.
(This question is part of a series of related questions that first enabled me to formulate these questions precisely (cf. How to "correctly" start an application from a shell and Is reparenting from the shell possible?). The three questions have been formulated and discussed partially in the comments of the two former questions but as I see it not been answered. Furthermore, they do seem more appropriate as short question in their own right not suited for discussion in comments.)
setsid sh -c 'firefox&' <> /dev/null >&0 2>&0
(note that it makes it immune to SIGINTs)setsid bash -c 'firefox; exit'
if you actually wantinit -- bash -- firefox
not connected to a terminal (setsid sh -c 'bash -c "firefox; exit" &'
to make sure thatbash
doesn't get control of a terminal if it ever opens one).