Is it possible and if so how do I:

  1. 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 as init -- bash. (Shells usually have the process tree structure terminal-emulator-of-your-choosing -- bash)
  2. Start a /bin/bash process not bound to a terminal that has as its child another process e.g. a browser like firefox from a shell session in a terminal? Hence, a shell process with a child that shows up in the process tree as init -- bash -- firefox.
  3. It is easy to get init -- firefox directly from the shell via something along the lines of exec 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.)

  • 1
    Yes, yes and yes. There, now the "Is it possible" part is answered. How is another beast altogether.
    – Braiam
    Aug 28, 2014 at 13:10
  • Yeah, I learned that the hard way... I tried and tried and searching the internet is not helpful either... Aug 28, 2014 at 13:34
  • 1
    Try setsid sh -c 'firefox&' <> /dev/null >&0 2>&0 (note that it makes it immune to SIGINTs) Aug 28, 2014 at 13:39
  • See also unix.stackexchange.com/q/68574/22565 Aug 28, 2014 at 13:46
  • 1
    Sorry setsid bash -c 'firefox; exit' if you actually want init -- bash -- firefox not connected to a terminal (setsid sh -c 'bash -c "firefox; exit" &' to make sure that bash doesn't get control of a terminal if it ever opens one). Aug 28, 2014 at 13:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.