cbrain icon indicating copy to clipboard operation
cbrain copied to clipboard

console() method for Bourreau to make sure we're using a different TTY

Open prioux opened this issue 9 years ago • 0 comments

The Bourreau objects have a console() command that allows a Rails console user to connect to the console of that bourreau. However, it will jam if the Bourreau's SshMaster control channel has been started from the very same terminal session as the one for the current rails console. It will work fine if started from a Rails console started in a different terminal. The problem is related to the TTYs, so a safety check that the console() method should do is:

  • get the TTY name of the SshMaster of the Bourreau
  • get the TTY name of the current console
  • if they're the same, raise an exception

I suggest adding a method to SshMaster: tty_name() which will return it. Maybe using the following ps command (which has been tested to work the same on MacOS X and Linux):

ps  -p 16897 -w -o pid=,tty=

which outputs a very simple one-line report for process 16897:

MacOS X:

16897 ttys008 

Linux:

16897 pts/0

prioux avatar Jan 12 '16 22:01 prioux