I have written a Ruby script to manage my LyX documents. The script has a short CLI interaction with the user(=me), and then it decides the name of the file to open, and opens it via a lyx shell command.

Now, the problem is, I need a terminal for the CLI interaction, but when I close the terminal, LyX pops a message box that says "SIGHUP signal caught! Bye." and when I click on OK, it closes LyX.

That problem occurred when I launched the shell via Ruby's exec command(that closes the ruby process and starts a new process for the given shell command). When I tried to replace it with a fork, the LyX windows never opened - my guess was that LyX received the SIGHUP when the Ruby script finished and the terminal closed - and I confirmed that guess when I added a gets command at the end of the Ruby script to prevent it from closing - and then the LyX window was opened, but when I pressed Enter to finish the ruby script, LyX received the SIGHUP and closed.

Now, I can probably solve this by replacing the CLI interaction with a GUI and giving up on the terminal window, but using a GUI for something like that seems like an overkill to me. So, is there a way to prevent LyX from closing when I close the terminal?

I'm running OpenSUSE 12.1 64bit with KDE, and the terminal emulator is Konsole.

1 Answer 1


One option is to run it with nohup:

nohup mycoollittlescript

Another would be to run it inside a terminal emulator like tmux or screen. These are terminal apps that are themselves terminal emulators. When the parent terminal is closed, they stay running in the backgrounmd and tyou can reconnect to them from another terminal window. Try this:

screen -R -d NameOfMyBackgroundJob

The first time this will create a new session. Repeated uses of the above command will connect to the existing session and disconnect it from any other terminal windows.

  • Thanks! The nohup solution worked! Though for some reason, it only works when I fork it from Ruby. If I try it directly from bash it doesn't work...
    – Idan Arye
    Commented Mar 4, 2012 at 0:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .