Monday, May 6, 2024
16
rated 0 times [  16] [ 0]  / answers: 1 / hits: 136597  / 1 Year ago, fri, april 28, 2023, 7:34:46

I'm using nano inside a MATLAB session that is running inside a screen (-x) terminal. I accidentally hit Ctrl-Z and it immediately leaves nano, prints "Use "fg" to return to nano", but does not show a command prompt. Whatever I type appears on the screen but nothing responds. If I hit Ctrl-Z, ^Z just prints to the screen. Any ideas? Using 12.04.


More From » command-line

 Answers
6

In the comments the author says that he or she is running the nano command from Matlab, and that there is no prompt whatsoever after suspending it with CTRL-Z. This is probably a bug in Matlab(1) which should not allow a CTRL-Z arrive to nano if it can't cope with it...



The problem is that the shell command fg (and bg, and jobs) works only with direct children of the shell. But you can continue a stopped process from another shell, although this will not guarantee that the status of the screen is correctly managed:




  1. in another terminal window, find the nano process:



    % ps ugx | grep nano
    romano 10600 0.0 0.0 20784 1628 pts/11 T 16:52 0:00 nano prova
    romano 10653 0.0 0.0 18256 900 pts/11 S+ 16:53 0:00 grep nano

  2. Notice that it is stopped (state T)


  3. Continue it with



    kill -CONT 10600 



...and hope it works (can mess up the terminal greatly). You can also trying a



killall -CONT nano 


that way the CONT signal is sent to all the "nano" processes (shouldn't be a problem though).





Footnotes:



(1) I tried with octave: EDITOR=nano octave and then edit file in octave. Pressing CTRL-Z messes the things up quite well... so maybe it's not Matlab but a strange interaction on who receive and manage the TSTP signal.


[#25176] Sunday, April 30, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
looweets

Total Points: 52
Total Questions: 114
Total Answers: 111

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;