Assume I have a long running process, long_running_proc with a single TCP connection to host host.example.com.

Is that process treated differently, by the OS or the shell, when it's run as a foreground process vs background or behind screen?

For instance:

~ long_running_proc --connect host.example.com


~ screen
~ long_running_proc --connect host.example.com
[ctrl-a] + d


~ long_running_proc --connect host.example.com &
[1] 67539

Are there different rules to process interruptions or context switches? Do they have a lower priority? Would I be more likely to get a TCP timeout with a screened/background process?

1 Answer 1


In general, by default the only difference is that it would receive a SIGTTIN (or SIGTTOU) signal if it tried to read (or write) the tty while being in the background.

Other differences as to priorities or higher context switches depend on your shell (or screen) if it willingly does anything of that sort, such as changing the process’s “nice” number or maybe binding it to one particular CPU and if that CPU happens to be interrupted a lot. Normally shells don't do anything of this sort unless requested.

Higher probability of getting TCP timeouts might be related to whether your process does get stopped by one of the above signals (due to attempted tty access), in which case it wouldn’t have any chance to receive and therefore reply to network traffic.

If you think of it, daemon processes are the most “background” processes possible, and they certainly aren’t second-class processes.

I can’t be exact about specifically screen’s detach operation but its documentation says that detached processes continue running, and that screen detaches itself from the process's tty, so the process goes on basically with no difference as to normal foreground or background operation. You would have difficulties at giving it commands, though, being your interactive terminal detached from the process's virtual terminal. This might not be good for your process if at some point it expects input from its terminal.

  • This is exactly what I was wondering. Thanks for the detailed response! I suppose it'll become somewhat process dependent at that point.
    – JonLuca
    Commented Apr 8, 2019 at 21:24
  • 1
    I believe in the case of screen a pseudo tty is used. When screen is detached the tty still exists and is still the controlling terminal of the process executed in screen.
    – Torin
    Commented Apr 8, 2019 at 21:30
  • @Torin @JonLuca True, thank you. I never use screen and had misunderstood its docs: I thought screen detaches the process but in fact it detaches itself from the process’s pty, so yes the process is still fully connected and controlled by that pty. Answer updated.
    – LL3
    Commented Apr 8, 2019 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .