Saturday, 8 June 2013

How to delay 500 ms in a screen keybinding sequence

How to delay 500 ms in a screen keybinding sequence

I'm trying to bind a key in screen so that it will send Ctrl-C to a process, wait a half second, and then quit.
In all examples below, ^C is a literal ^C, typed into something like vi using ctrl-v ctrl-c.
The process takes a moment to shut itself down, so this form doesn't work:
bind ^\ eval 'screen 0' 'select 0' 'stuff ^C' quit
Presumably it delivers the ctrl-C and the process starts to shut down, but it doesn't get far enough.
This example doesn't work – screen just kills the sleep process and exits:
bind ^\ eval 'screen 0' 'select 0' 'stuff ^C' 'exec sleep .5' quit
I thought of trying to abuse slowpaste to accomplish what I want, but don't know how to get literal characters into the paste buffer. These examples don't work:
bind ^\ eval 'screen 0' 'select 0' 'stuff ^C' 'slowpaste 500' 'paste .' quit
bind ^\ eval 'screen 0' 'select 0' 'stuff ^C' 'slowpaste 500' 'paste abc' quit
bind ^\ eval 'screen 0' 'select 0' 'stuff ^C' 'slowpaste 500' 'stuff abc' quit
Any other ideas on how to give the process a chance to respond to SIGINT, then quit?

No comments:

Post a Comment