0

I have a .NET program (Edit: using MONO), call it myfoo that resides on my remote ubuntu server. To access it, I ssh into my box (using wifi, not ethernet). My bash shell starts up as normal, I cd to the directory, and then run the program via mono myfoo. this all works fine.

Unfortunately, the company where I work has some pretty obnoxious wifi problems. The short version is that the vpn craps out every now and then, so while my device stays connected to the wifi, the whole network connection is severed to my server.

Naturally, this causes my device to eventually realize the connection is gone, and displays the traditional broken pipe error. Now, here's the problem:

When I re-connect, and start myfoo again, it doesnt work. I've tracked down the problem to the fact that when the connection breaks, bash doesn't end the previous instance of myfoo. I have to manually kill the previous instance before starting the new one. For various reasons, this is a problem. I would have expected that when the connection broke, bash would exit, and therefore kill any children it spawned. Apparently, that isn't happening. Is there a way I can MAKE it happen? I would prefer not to change the sourcecode of the program, but if I need to in order to catch an interrupt or something I can. I would prefer if there was some solution in my bash profile settings or something that would allow this behavior to take place.

  • Have you considered using something like GNU Screen? – heavyd Jun 25 '14 at 17:29
  • Why is this tagged as Linux? If its on Ubuntu its not using .NET Framework its a Mono Framework application. – Ramhound Jun 25 '14 at 17:40
  • @heavyd I use screen for many things, and it is fantastic, but for this application it will not work. – Russell Uhl Jun 25 '14 at 18:35
  • @Ramhound: It's tagged linux because the app runs on...linux. AKA, is there something i can do in LINUX to get the behavior i want? – Russell Uhl Jun 25 '14 at 18:35
  • @Ramhound, there is no such thing as a "Mono Framework application." .NET apps are .NET apps whether the particular implementation of the common libraries is provided by Microsoft or Mono or some other framework implementation the app doesn't have to change. – heavyd Jun 25 '14 at 19:22
1

If using OpenSSH, you can enable keep alive packets that will detect the dropped connection and end the ssh session, causing bash to exit:

ssh -o ServerAliveInterval=2

That will send a keep alive every time two seconds pass without any packets. If three consecutive keepalives are missed (can be changed by setting -o ServerAliveCountMax=10), the connection will close.

  • this looks promising. I'll try it out today and see how it goes – Russell Uhl Jun 26 '14 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.