How to disconnect a process from a terminal in unix?

When I run the process in the background in the terminal, and some, as if the terminal is closing, we can no longer interact with this process. I'm not sure, but I think the process is also killed. Can someone tell me how I can separate this process from my terminal. Therefore, even if I close the terminal, can I interact with the same process in the new terminal?

I am new to unix, so your additional information will help me.

+5
source share
4 answers

You can also consider the team screen. It has a function to "restore my session." Admittedly, I never used it and forgot about it.

nohup , , stdout/stdin.

. google try, "unix screen command" "unix screen tutorial":

+5
+13

Google "UNIX demonizing a process":

. daemon (3). - , -. , :

  • fork()
  • setsid()
  • / stdin/stdout/stderr /dev/null / SIGHUP/SIGPIPE.
  • chdir() /.

, , , root , . , "", "" setuid()/setgid(). , seteuid() , .

, , exec, close exec , .

HOWTO Unix: http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html

+3

" " .

, , , , , , , , HUP (. kill(1) : HUP, , "" , /). HUP , , .

, .

nohup , HUP . , .

- , (. kill(1) ), , , , ( USR1 USR2 , - ). , (IPC). .

, , . , , screen, , .

A thing nohupis a kind of quick and dirty demonization. The daemon(3)function demonizes “correctly” by executing various order bits, as described in YePhIcK's answer, to completely break the connection with the process / terminal it called. You can interact with this demonized process with the same IPC tools as above, but not just with the terminal.

0
source

All Articles