On X startup the following is ran automatically:

xterm -e screen -rS app1

This opens up an xterm session and attaches the screen of app1, which was already running in a detached state.

What I'd like to achieve is the ability to close the xterm window, using ctrl-c, without terminating the GNU screen session. The exhibited behavior when pressing ctrl-c is that app1 and the screen session terminates.

I was reading on the autodetach feature but so far and I haven't been successful and I don't know if this is what I need.

I'm running KDE with SLES 11.3.

  • Have you tried the screen detach commands, such as Ctrl-A d ? – Herb Wolfe Jan 6 '18 at 20:50
  • Yes I suspect this would work, except the users of the system would not know of it, and would probably resort to ctrl-c to close the window. – joueffy Jan 6 '18 at 21:34

"Closing an xterm window" is not typically done with Ctrl-C. What's probably happening is that the application is catching it (SIGINT) and exiting gracefully, leaving the screen session, leading to closing the terminal (window).

Your goal seems to be that Ctrl-C should be handled by screen to detach the application, which can be done by the screen mapping:

bindkey "\003" detach

You can issue this to test with Ctrl-A : then entering the above. The syntax is the same for a custom .screenrc, but don't put it in there for any user, noone will be able to break out of any program inside that screen! If you have the above, and an autodetach on in a .my.screenrc file, then you can invoke the original with screen -c .my.screenrc, then start the application inside.

I repeat, be aware that now screen is instructed to catch the interruption, no program started in this screen, not even programs started by your application can be stopped if they misbehave/hang, just from another terminal.

The autodetach option will take care of closing the window normally from your window manager.

  • wow! exactly what I was looking for. Thanks! – joueffy Jan 8 '18 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.