bug-bash
[Top][All Lists]
Advanced

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

Re: TIMEOUT


From: Greg Wooledge
Subject: Re: TIMEOUT
Date: Mon, 6 Apr 2009 08:26:41 -0400
User-agent: Mutt/1.4.2.2i

On Sat, Apr 04, 2009 at 08:37:32AM -0300, Sergio Charpinel Jr. wrote:
> So, first of all, I'm trying to find a way to combine TMOUT variable with
> vlock.

What's vlock?

> I just found a way to do this in zhs. And if it is not possible, I
> need to set TIMEOUT just for root, and it can't logout when root is using
> screen.
> I tried to do something, but I'm new in bash. My "script" didnt work.
> 
> for f in $( ps ax ); do
>     if [ $f == "SCREEN" ]; then
>         export TMOUT=0
>     fi
> done

OK, it looks like what you're trying to do is "set the TMOUT variable
unless I am running inside screen".  So the trick, then, is to determine
whether you are running inside screen or not.

I can think of two ways to do that: checking the "command" (argv[0])
of every parent process up through the chain to init; or looking for
environment variables that would only be set when you're inside screen.
The former is really, really bad (and your script looks like it might
be attempting it, although it's doing it incorrectly).  So let's look
at the latter instead.

A quick check through the screen(1) man page yields this:

       setenv [var [string]]

       Set the environment variable var to value string.  If only var is spec-
       ified,  the  user  will be prompted to enter a value.  If no parameters
       are specified, the user will be prompted for both variable  and  value.
       The environment is inherited by all subsequently forked shells.

So, what I would do is put one of these setenv commands into my
~/.screenrc and then check for whatever environment variable you've
decided to set, when you're in .bashrc and deciding whether to set
the TMOUT variable.  Like so:

~/.screenrc:
  setenv I_AM_INSIDE_SCREEN 1

~/.bashrc:
  if [[ ! $I_AM_INSIDE_SCREEN ]]; then
    TMOUT=300
  fi

If you need this to be done only for root, then you would do this in
root's home directory and nobody else's.




reply via email to

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