Web lists-archives.com

Re: TCP proxy for host on subnet




On 06/06/2017 18:03, Greg Wooledge wrote:

Once you're ready to deploy it, you would want to set it up as an
automatically respawning service, under systemd or one of the other
service managers.


I seem to be having a problem stopping socat under Wheezy LTS using /etc/init.d. I've created a socat start/stop script (by editing the example file provided by Debian in /etc/init.d/skeleton). Then:

# service socat start

works, socat runs, logs the uses of the proxy, and so on. But, the 'session', in the sense of the keyboard and screen, still runs and does not go into any kind of background. Sure, I realise I am running from a terminal - but my uncertainty is that this 'continuous session', as it were, will remain whether I start the script from cron every morning (say), or automatically from the /etc/rc[n].d directories.

Further, I don't seem to be able to *stop* socat without pressing ^C in the session, suggesting to me that cron won't be able to, either. I tested trying to stop socat, but from another session, to emulate what would happen if I used cron to start socat every morning (say) and also to stop it late at night; I used 2 terminal sessions to emulate cron giving the separate morning and night commands. Here's what happened:

terminal-session-1 # service socat start
  <blank line, no prompt, socat is working at this point>

another-terminal-session-2 # service socat stop
  <another blank line, no prompt, but socat *continues* to run>
  < long wait >
  < eventually, ^C>

another-terminal-session-2 # <prompt reappears>

*also*, then on the first session,

Killed
terminal-session-1 # <the prompt reappears>

This test reveals that starting socat is fine, but only a user and actual process running socat can stop it and even then it has to get back into some kind of 'command' mode to do so.

[I was surprised that
# service socat stop
did not stop socat - the script (it is just debian's standard script) references the process by its pid which it determines using the line
PIDFILE=/var/run/$NAME.pid
(and NAME=socat)
but it still does not stop it.]

In principle, how should a system be configured so that something like socat can be started, and stopped?

regards, Ron