2015-04-08 11 views
5

Dato un esempio di script che si apre /dev/tty:/dev/tty si apre in nailgun-terminal server

# sample.rb 
tty=File.open("/dev/tty", "w+") 
tty.print "> " 
tty.puts tty.gets.upcase 

posso eseguirlo con JRuby normale bene:

% jruby sample.rb 
> hello 
HELLO 
% 

Tuttavia, se provo da utilizzare con /dev/tty nailgun, allora la tty è legato al server nailgun, non il cliente:

# server terminal          | # client terminal 
% jruby --ng-server         | 
NGServer 0.9.1 started on all interfaces, port 2113. | 
                 | % jruby --ng sample.rb 
> hello            | 
HELLO             | 
                 | % 

(la spaziatura verticale è per mostrare i tempi, l'uscita effettiva per ciascuna manca le righe vuote)

È questo comportamento previsto o un errore?

Se ci si aspetta un comportamento, c'è un modo che posso rilevare se uno script viene eseguito con --ng così posso evitare aperture /dev/tty?

risposta

0

Guardando allo Nailgun client/server protocol, non sembra che supporti ciò che dovrebbe accadere per utilizzare il client /dev/tty (avere un client aprire un file, leggere/scrivere dal client al server).

Che si tratti di un bug o meno, al momento è fuori dalle capacità di Nailgun.

Rilevare se siamo su un server Nailgun può essere fatto tramite

# true if on a nailgun server, false elsewise 
system("ps -fp #{Process.pid} | grep NGServer > /dev/null") 
Problemi correlati