Re: Trouble writing background-running program



"Carlos" == Carlos Moreno <cm_news@xxxxxxxxxxxxxx> writes:

Carlos> I connect remotely to the server (using an X-terminal on
Carlos> my local machine running GNOME) through SSH to run the
Carlos> program.

You're not using an X-terminal. You're using an xterm. These are
different things. Very different.


Carlos> No matter what I do, after I run the program, my console
Carlos> seems to hold on to the connection and doesn't let go.

Carlos> I run the program and then I run logout or Ctrl-D, and the
Carlos> X-terminal does not return to my local shell. If I close
Carlos> it forcibly (kill or simple the close button of the
Carlos> window), then ok, and the remote process does remain
Carlos> running in the background.

Since you said you've followed the books on daemon-writing, I assume
you've detached from terminal and setsid() properly. Then, there is
the possibility that your program has opened ports that have been
forwarded by ssh (-L or -R). While these ports remain open, ssh will
strive to stay alive, because it needs to be alive to maintain the
forwarded ports. If you kill -9 the ssh (or sshd on remote side)
process, the forwarded ports will be broken, and your program may
suffer. However, you may put ssh into background using -f. Interactively,
type <Enter> ~ Ctrl-Z bg or <Enter> ~ &.



--
Lee Sau Dan 李守敦 ~{@nJX6X~}

E-mail: danlee@xxxxxxxxxxxxxxxxxxxxxxxxxx
Home page: http://www.informatik.uni-freiburg.de/~danlee
.


Quantcast