screen-users
[Top][All Lists]
Advanced

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

Re: Killing backticks when bouncing screen.


From: Gerhard Siegesmund
Subject: Re: Killing backticks when bouncing screen.
Date: Fri, 23 Jan 2009 17:11:45 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hello CJ

I, for example, use the following script to monitor the number of
messages on my mailbox:

------------------------------------------------------------------------
#!/bin/sh

FETCHMAIL='/usr/bin/fetchmail'

while true; do
  $FETCHMAIL -c | sed -e 's/.* \([0-9]*\) messages* (\([0-9]*\) seen.*/\1 - 
\2/g' | bc || exit 1
  sleep 60
done
------------------------------------------------------------------------


I had the same problem as you. What fixed the problem was the '|| exit
1'-Statement.

The point is, when the terminal where the script writes to doesn't exist
anymore, then the outputting tool should signal this with an exitcode
other than 0. With '|| exit 1' in my example I check whether bc was able
to correctly output its result. If that was not possible, end the script
with 'exit 1'.

This way everytime my screen instance is killed, all the running
backtick-Scripts also end.

Hope this helps.

Greetings

> I have written a few scripts that display monitoring counters on the
> hardstatus line.
> 
> Thinking I would avoid the overhead of starting new processes,
> particularly for stuff that requires frequent updates in order to be
> relevant ..  such as CPU utilization, I thought I'd write scripts that
> run in the background & iterate for ever over the following: acquire
> data, format & write to stdout, sleep a while, etc.
> 
> The corresponding backtick commands in my .screenrc specify values of
> zero for "lifespan" & "autorefresh" - as documented on the screen man
> page:
> 
> "If both the lifespan and the autorefresh parameters are zero, the
> backtick program is expected to stay in the background and generate
> output once in a while.  In this case, the command is executed right
> away and screen stores the last line of output.  If  a new line gets
> printed screen will automatically refresh the hardstatus or the
> captions."
> 
> The problem is that, if for some reason or other, I terminate the
> GNU/sreen instance, the orphaned processes still run under the init
> process.
> 
> As I was testing the layout of my hardstatus line the other day, I
> eventually noticed--thanks to my monitoring, and the laptop's fan
> kicking in :-) .. that I was using dollops of ram & cpu cycles .. well,
> it turned out some 20-30 instances of my scripts and the related sleep
> subprocesses were still running in the background.
> 
> Whenever I shut down a screen instance (manually terminating each
> individual application), I would need to terminate those scripts as
> well.. at the same time GNU/screen issues the "screen terminating"
> message.
> 
> The problem is how?
> 
> Has anyone gone down this road before and found a clean solution?
> 
> Thanks,
> 
> CJ
> 
> 
> _______________________________________________
> screen-users mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/screen-users

-- 
cu
  --== Jerri ==--
Homepage: http://www.jerri.de/   ICQ: 54160208
Public PGP Key: http://www.jerri.de/jerris_public_key.asc

Attachment: signature.asc
Description: Digital signature


reply via email to

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