screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screen staying alive after ctrl+c-ing its initial task


From: Philipp Haselwarter
Subject: Re: Screen staying alive after ctrl+c-ing its initial task
Date: Tue, 12 Feb 2013 01:58:36 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

Here's a little script that does what you want.

There are two issues with "screen -d -m ":
- it double-forks, so the created session's pid can't be
  captured
- it might exit before the new session is ready

Therefore I had to resort to forking with -D and polling.


--8<---------------cut here---------------start------------->8---
#!/bin/sh
# args: $1 : session-name, $2 : shell command to run
session=$1
screen -c /dev/null -S $session -D -m &
session="${!}".$session
until screen -c /dev/null -S $session -X echo ''; do sleep 0.1; done
screen -c /dev/null -S $session -X stuff "$2\015"
--8<---------------cut here---------------end--------------->8---


-- 
Philipp Haselwarter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]