0

In order for a process to survive its parent shell's exiting, what necessary and sufficient conditions does the process need to meet?

  1. Specifically considering signals, what signals should be ignored by the process or not sent to the process?

    • SIGHUP, SIGTERM?

      But nohup makes a process ignore only SIGHUP, not SIGTERM? (disown seems to avoid the parent shell sending any signal to the process)

    • Terminal generated signals, such as SIGINT, SIGQUIT, SIGTSTP, SIGTTIN, SIGTTOU?

      But disown and & (background) don't disconnect a process from its controlling terminal. (nohup can disconnect a process from its controlling terminal).

  2. Besides signals, are there other necessary conditions in other aspects than signals?

  3. How do you make a process survive its parent shell's exiting, given the conditions above?

  4. Is the task of making a process survive its parent shell's exiting same as the task of changing the parent of the process?

    In bash shell and basic utilities (e.g. coreutils), are disown and nohup the only two ways to change the parent shell process of a process? Does the parentage change happens when the shell exits?

  • Too many questions – Giacomo Catenazzi Mar 1 '16 at 20:53
  • A dying shell shouldn't be sending any signals other than SIGHUP (disown or nohup prevent this). You could get a SIGPIPE if your stdout or stderr was a terminal, that terminal went with the shell, and you attempt output something. Ignoring SIGPIPE and SIGHUP should therefore be enough. – PSkocik Mar 1 '16 at 21:07
  • @PSkocik: SIGPIPE is about a pipe. "If your stdout or stderr was a terminal, that terminal went with the shell, and you attempt output something", there is no pipe here, isn't it? How can the signal be SIGPIPE? What should the signal be? (If I am correct, SIGTTOU is for the case when the terminal still exists) – Tim Mar 1 '16 at 21:44
  • 1
    My bad. I've played with it and my processes connected to a dead terminal are not getting SIGPIPE. (SIGPIPE isn't limited to pipes though -- you get it with sockets too). – PSkocik Mar 1 '16 at 22:07

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.