   Can a background process simply vanish?
  Hello.I have two unrelated executables that I started like this:1) opened a ssh shell2) Started the two applications$ mfsrv &$ chatsrv &3) Exited the shell$ exitToday when I logged in to my server both were gone!Both programs are written by myself. chatsrv runs an endless loop and never terminates programmatically.mfsrv terminates programmatically but it prints a message in the log. No message was there.I made the following checks:1) Checked core dumpsI found no cores.My ulimit is set to 'unlimited', and my system is set to dump cores in the cwd.None of these processes ever changes the cwd. I wouldn't be suprised if one of them had cored.But both! They are totally unrelated.2) Checked if the system had rebootedlast bootit didn't reboot3) Check if someone else had accessed my serverlast -xI was the last one to access the server.What is going on?Normally 'ps -eaf' prints this, when the 2 processes are running:UID   PID  PPID  C STIME TTYTIME CMDmfoot79371  0 13:17 ?   00:00:00 ./mfsrvmfoot80121  0 13:21 ?   00:00:00 ./chatsrvIs the kernel terminating my processes?   
Quote:Original post by hiigaraIs the kernel terminating my processes?No, you are terminating your processes.When a parent process (process group leader) terminates, so do its children.  You can't just backgrund a job from the shell and log out.  You need to set the jobs into their own process groups.One way to do this is to write your process as a daemon.  You need to detach from controlling terminals and create a new process group (fork/fork/setsid etc).A simpler way is to use the nohup command.  $ nohup mfsrv >mfserv.log 2>&1 </dev/null &  $ nohup chatsrv >chatserv.log 2>&1 </dev/null &;Quote:Original post by BregmaNo, you are terminating your processes.]No, I am not. Both servers are accessible through a client I have on my windows PC. And that's how I have been starting the servers for a year now. It works in both suse linux and ubuntu. I just exit the shell and the servers keep running.Quote:One way to do this is to write your process as a daemon.  You need to detach from controlling terminals and create a new process group (fork/fork/setsid etc).A simpler way is to use the nohup command.  $ nohup mfsrv >mfserv.log 2>&1 </dev/null &  $ nohup chatsrv >chatserv.log 2>&1 </dev/null &Thanks I will use nohup, creating deamons with system calls is hard work.But still I would like to know exactly why my servers were killed.;Quote:It works in both suse linux and ubuntu. I just exit the shell and the servers keep running.It probably doesn't. What most likely happens on Suse and Ubuntu is that your ssh session gets stuck. I.e. you disconnected but the remote session doesn't really close. After a while you will have many dead tty processes eating up resources.Instead of nohup, you can also look at the start-stop-daemon command. With that you can use regular applications as daemons. They run separately and will not terminate when you close your session.   ;Quote:Original post by SanderInstead of nohup, you can also look at the start-stop-daemon command. With that you can use regular applications as daemons. They run separately and will not terminate when you close your session.Keep in mind start-stop-daemon is a Debian thang.  It's not generally available in Red Hat and derivatives.  The LSB standard assumes that a daemon process is a daemon, so there is no mandated cross-platform tool to wrap a non-daemon in a portable way.  Except for maybe nohup.   ;Quote:Original post by BregmaKeep in mind start-stop-daemon is a Debian thang.Ah yes, of course. All I ever use is Debian-based distros :-) Though according to Google, Gentoo seems to have it. Fedora/RedHat/CentOS have "daemon" which is supposed to be similar.;  Type "man daemon"DAEMON(3)   Linux Programmer’s Manual  DAEMON(3)NAME  daemon - run in the backgroundSYNOPSIS  #include <unistd.h>  int daemon(int nochdir, int noclose);...DESCRIPTION  The daemon() function is for programs wishing to detach themselves from  the controlling terminal and run in the background as system daemons.It's not POSIX, but it's in any remotely recent glibc.   ;  You can use screen also to run those processes.   