PasTim wrote: 
> Yes, but it took me most of an evening to discover little wrinkles.  I
> went round many, many possibilities and variations before making it
> stable.
> 
> I had produced a script to run it all, starting with "killall socat &&
> soc....", and quite often it failed.  I think what was happening was
> that the killall didn't complete before the socat got up and running, so
> killed it.  Putting the killall on one line and socat on the next seemed
> to fix it.  Strange.
> 
> I had also added a "killall socat &&" to the Remote command line in the
> .ssh config.  That similarly caused random havoc, so had to go.

Ah that's a shame the process is still a bit brittle.

Are you certain there was no SP process running prior to kicking off the
socats and ssh? In my case, if that was so, I also experienced the kinds
of wrinkles you described. The issue is with the "fork" option on socat
- if it's running and there's application traffic on that UDP port being
generated by SP, it forks off a child process to handle it. So there may
be a race condition with the "killall socat" killing off the parent
process but leaving a child, or vice versa.  For more insight killall
also provides a "-v" option which describes what processes it's killing
more verbosely.

By using the shell "cmd1 && cmd2" operator, this should absolutely
ensure that cmd2 is not invoked before cmd1 terminates, and moreover,
terminates successfully. Alternatively you can use "cmd1; cmd2" for
serial execution of 2 commands on a single line - in that case cmd2
always runs after cmd1 irrespective of the exit status of cmd1. So I
don't think the issue is the killall not completing before with socat is
launched.

I have not tested putting shell operators like "&&" or "&" into the
RemoteCommand line in ~/.ssh/config. But it would not surprise me if
these don't work as intended. It would all come down to the exact way
ssh forks off the remote shell and passes the command + arguments to it.
I would recommended that if you need to use "&&" or "&" operators, it's
best to put everything into a single shell script file and just launch
that from the RemoteCommand directive (which is what I think you ended
up doing). Make you you specify the full path to your shell script on
the remote machine.

It would not hurt to put a killall socat into the remote command script.
If you are doing it on one line, make sure you use "&&"  or ";" (not
"&") to separate the killall and the socat. Of course, if you place
these commands on separate lines, this would also ensure the commands
are executed sequentiually rather than in parallel. In my case however,
I found that in 100% of the cases when I killed the ssh session with
Ctrl-C, it always killed off the remote socat(s) as well. So I found I
didn't need that remote "killall socat". But again, depending on the OS
and versions of SSH used etc., it wouldn't surprise me if in some cases
the remote socat is left running in the background and should be killed
off explicitly.

Sometimes it's better to go with simpler solutions to these things
rather than trying to come up with clever 1-liners :)


------------------------------------------------------------------------
nico's Profile: http://forums.slimdevices.com/member.php?userid=672
View this thread: http://forums.slimdevices.com/showthread.php?t=108734

_______________________________________________
Squeezecenter mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/squeezecenter

Reply via email to