2012-03-11 48 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