2012-03-11 77 views
4

我已经建立了一个布fabfile用一个简单的任务,给我一个远程交互的shell:远程交互shell被CTRL-C杀死

def shell(): 
    open_shell() 

我做到这一点,而不是原始ssh来拯救键入:fabfile已经有每个远程配置的关键路径,主机名等。

调用

fab shell 

作品,但如果我打CTRL +Ç外壳,它杀死了整个连接。

是否有可能使CTRL + C转而远程交互式shell?

+1

注意:从面料1.6开始,默认情况下这是固定的。有一个环境变量来控制它 - http://docs.fabfile.org/en/1.8/usage/env.html#remote-interrupt – Nils 2014-02-21 20:45:10

回答

2

我见过的使用ssh rfc描述的信号传递机制的python中唯一一个ssh库是chilkatsoft中的一个。 从RFC 4254:

6.9. Signals 

A signal can be delivered to the remote process/service using the 
following message. Some systems may not implement signals, in which 
case they SHOULD ignore this message. 

    byte  SSH_MSG_CHANNEL_REQUEST 
    uint32 recipient channel 
    string "signal" 
    boolean FALSE 
    string signal name (without the "SIG" prefix) 

'signal name' values will be encoded as discussed in the passage 
describing SSH_MSG_CHANNEL_REQUEST messages using "exit-signal" in 
this section. 

您可以修改面料使用,而不是“SSH”库,然后将信号处理程序添加到织物赶上SIGINT和调用SendReqSignal()来发送其传递给远程过程。

或者你可能只是用stty invocations包装结构来将INTR字符改为别的东西,然后再改回来。

#!/bin/sh 
stty intr ^U 
<whatever to invoke fabric> 
stty intr ^C 
+0

RFC4254也是一个正常的SSH客户端如何转发信号到远程端?有趣... – Nils 2012-03-12 00:03:24