Misha Koshelev
2010-Apr-21 12:17 UTC
prototype of simple NX client with auto-resuming ssh session
Dear All: --- Summary, especially for openssh list (to test/reproduce): THANK YOU for all your help. Please extract into /home/username/nx on both host and client. cp ssh to a file named mxssh in that directory. Run (with an _n_ below) Start server on the remote host by typing ./server & Now do: ./nxssh hostname If you killall client on the remote end, it reconnects "seamlessly" (I am using this to simulate ServerAliveInterval). However, if I do this from _within_ the nxclient program it _detects_ my disconnect even though the thread is still running (I believe). Any ideas? Thank you Misha p.s. Also right now I have functionality to spawn the server directly from the client, but somehow the signal(SIGHUP,SIG_HUP) command causes _both_ the server and client to ignore SIGHUP, even though it is called _only_ in the client. Any ideas? Thank you! --- Thank you so much for your help. I have put my current prototype on the Web at: people.hnl.bcm.edu/misha/tmp/nx.zip Includes source code, and binary executables for amd64. Right now, expects to live in the /home/username/nx folder on the remote machine (machine being connected to). Expects nx certificates in right places (/usr/NX). The nxssh requires an ssh executable to be in the same directory called mxssh (say original nxssh from NoMachine or even plain old ssh for command line testing). Currently, I (1) get a _seamless_ connection from the command line however (2) nxclient somehow detects intermediate disconnects Note the NX part works until a disconnect (I just do killall cient). Thank you! Misha
Misha Koshelev
2010-Apr-21 22:08 UTC
prototype of simple NX client with auto-resuming ssh session
Keisial wrote:> Misha Koshelev wrote: >> p.s. Also right now I have functionality to spawn the server directly from the client, but somehow the signal(SIGHUP,SIG_HUP) command causes _both_ the server and client to ignore SIGHUP, even though it is called _only_ in the client. Any ideas? Thank you! >> > (I assume you mean SIG_IGN, not SIG_HUP) > > The server inherits the ignoring of SIGHUP. From signal(7) >> A child created via fork(2) inherits a copy of its >> parent's signal dispositions. During an >> execve(2), the dispositions of handled signals are reset to the >> default; the dispositions of ignored >> signals are left unchanged. > > Perform signal(SIGHUP, SIG_DFL); after the fork but before the execv (or > simply set SIGHUP to whatever you want in the server). >I am sorry. Not sure what I was on when writing my email this morning ;) What I meant is the following. I have machine A from which I am connecting, machine B _to_ which I am connecting. Two scenarios: i) I start server on machine B. Then, from machine A, I do ssh B nx/client. Now, on machine B, I do killall client. SIGHUP is sent, client dies, ssh session from machine A ends. ii) I ssh B nx/client; the _client_ spawns the server. Now, on machine B, when I do killall client, the client dies but SSH DOES NOT DISCONNECT! Why would this be? Thank you Misha Koshelev p.s. The other problem is as follows: in the "nxssh" executable, I have a while (1) loop where I _fork_ to start a child process, and then execl ssh. The parent simply has a wait(NULL) call. Now, from the command line, this creates the illusion of a seamless SSH session after disconnects. However, nxclient somehow detects this. Any ideas?
Misha Koshelev
2010-Apr-21 22:12 UTC
prototype of simple NX client with auto-resuming ssh session
Keisial wrote:> Misha Koshelev wrote: >> p.s. Also right now I have functionality to spawn the server directly from the client, but somehow the signal(SIGHUP,SIG_HUP) command causes _both_ the server and client to ignore SIGHUP, even though it is called _only_ in the client. Any ideas? Thank you! >> > (I assume you mean SIG_IGN, not SIG_HUP) > > The server inherits the ignoring of SIGHUP. From signal(7) >> A child created via fork(2) inherits a copy of its >> parent's signal dispositions. During an >> execve(2), the dispositions of handled signals are reset to the >> default; the dispositions of ignored >> signals are left unchanged. > > Perform signal(SIGHUP, SIG_DFL); after the fork but before the execv (or > simply set SIGHUP to whatever you want in the server).In other words - this does not actually happen. In fact, I do _nothing_ to signals at all in the client, but when I spawn the server _from_ the client ssh will not disconnect even if the client dies... Any ideas? Maybe its not a signal issue at all. Thank you! Misha