簡體   English   中英

帶Fabric的遠程交互式Shell被CTRL-C殺死

[英]Remote interactive shell with Fabric is killed by CTRL-C

我用一個簡單的任務構建了一個fabric fabfile,為我提供了一個遠程交互式shell:

def shell():
  open_shell()

我這樣做是為了代替原始ssh來保存輸入內容:fabfile已經具有每個遠程配置的鍵路徑,主機名等。

調用中

fab shell

可以,但是如果我在外殼中按CTRL + C ,它將終止整個連接。

是否可以使CTRL + C轉到遠程交互式外殼?

我見過的python唯一使用ssh rfc描述的信號傳遞機制的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調用包裝結構,以將INTR字符更改為其他字符,然后再將其更改回。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM