zsh-users
 help / color / mirror / code / Atom feed
* TRAPNAL with TMOUT problem
@ 2000-08-21  5:58 Paul Lew
  2000-08-21 17:48 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Paul Lew @ 2000-08-21  5:58 UTC (permalink / raw)
  To: zsh-users

I have been setting the TMOUT value and defining TRAPALRM function to
perform some background operation.  However, there is a side-effect I
did not expect:

The 'idle' time for command 'w' is now affected by the invocation of
TRAPALRM function, i.e., if I defined TMOUT to be 3600, zsh will never
show idle more than 60 minutes.

This is not good because I have been using this to track co-worker's
activity so we can roughly know if a user is logining on.  Now this
information is no longer useful.  Any idea what's the best solution
to this?  Thanks.

BTW, I am using zsh-3.1.9 on Solaris 2.6 with /usr/ucb/w command.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TRAPNAL with TMOUT problem
  2000-08-21  5:58 TRAPNAL with TMOUT problem Paul Lew
@ 2000-08-21 17:48 ` Bart Schaefer
       [not found]   ` <14754.42242.721509.918727@paullew-ultra.cisco.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-08-21 17:48 UTC (permalink / raw)
  To: Paul Lew, zsh-users

On Aug 20, 10:58pm, Paul Lew wrote:
> Subject: TRAPNAL with TMOUT problem
> 
> The 'idle' time for command 'w' is now affected by the invocation of
> TRAPALRM function, i.e., if I defined TMOUT to be 3600, zsh will never
> show idle more than 60 minutes.

The "idle" time is nothing more than the difference between the access
time and the modification time of the tty device file for the associated
terminal.  I have a TMOUT/TRAPALRM that updates the title bar of my xterm
every 60 seconds, yet my w output still shows me as having been idle all
weekend on terminals I haven't touched yet this morning.

Probably what's happening is that the terminal is getting "accessed" when
the background job runs.  (My traps use only builtins, so no new job group
needs to become associated with the terminal.)

Try starting the background jobs with stdin/out/err all redirected and a
trailing &! token to "disown" them.  I'm not certain that wll prevent zsh
from associating the job with the terminal, but it's easy to test.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TRAPNAL with TMOUT problem
       [not found]   ` <14754.42242.721509.918727@paullew-ultra.cisco.com>
@ 2000-08-22 18:24     ` Bart Schaefer
       [not found]       ` <14757.19686.238318.996093@paullew-ultra.cisco.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2000-08-22 18:24 UTC (permalink / raw)
  To: Paul Lew; +Cc: zsh-users

On Aug 22,  9:06am, Paul Lew wrote:
} Subject: Re: TRAPNAL with TMOUT problem
}
} >>>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
} 
}     Bart> Probably what's happening is that the terminal is getting
}     Bart> "accessed" when the background job runs.  (My traps use only
}     Bart> builtins, so no new job group needs to become associated
}     Bart> with the terminal.)
} 
} This is what I have defined:
} 
} TRAPALRM () {
}         local howner
}         howner=$(host_owner) 
                 ^^^^^^^^^^^^^
		 My guess is that this command substitution causes the
		 tty to be accessed, via utils.c:attachtty(), thereby
		 changing the idle time.
}         if [[ $howner != $LOGNAME && $howner != "" ]]
}         then
}                 echo "exit non-allocated machines"
}                 exit
}         fi
} }
} 
} host_owner () {
}         awk '$1 == "'"$HOST"'" {print $4}' $ar/etc/devhost
} }
} 
} Here the content of file devhost might change by other programs.
} Could you find anything suspicious here?  Should I redirect I/O on the
} awk command line?  Thanks..

Redirecting awk's I/O isn't going to help because $(...) creates a sub-
shell that may do its own attachtty() before starting awk.  So what you
may have to do is avoid using a command substitution.

Something like this:

TRAPALRM () {
        local howner
        host_owner
        if [[ $howner != $LOGNAME && $howner != "" ]]
        then
                echo "exit non-allocated machines"
                exit
        fi
}

host_owner () {
	setopt localoptions no_ksh_arrays
	local devhostent
	while read -A devhostent
	do
		if [[ $devhostent[1] == $HOST ]]
		then
			# howner in scope of caller!
			howner=$devhostent[4]
			return
		fi
        done < $ar/etc/devhost
}

See if that doesn't help.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: TRAPNAL with TMOUT problem
       [not found]       ` <14757.19686.238318.996093@paullew-ultra.cisco.com>
@ 2000-08-24 17:27         ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2000-08-24 17:27 UTC (permalink / raw)
  To: Paul Lew; +Cc: zsh-users

On Aug 24,  9:27am, Paul Lew wrote:
> Subject: Re: TRAPNAL with TMOUT problem
> >>>>> "Bart" == Bart Schaefer <schaefer@candle.brasslantern.com> writes:
> 
>     Bart> host_owner () {
>     Bart>	setopt localoptions no_ksh_arrays
>     Bart>	local devhostent
>     Bart>	while read -A devhostent
>     Bart>	do
>     Bart>		if [[ $devhostent[1] == $HOST ]]
>     Bart>		then
>     Bart>			# howner in scope of caller!
>     Bart>			howner=$devhostent[4]
>     Bart>			return
>     Bart>		fi
>     Bart>	done < $ar/etc/devhost
>     Bart> }
> 
> I tried this and the result is still the same.  Which part of these
> procedures touched the tty device?  Thanks..

I just ran through calling the above from TRAPALRM while watching zsh with
strace.  Unless there's an error (/etc/devhost not found or not readable are
pretty much the only possible ones), *nothing* touches the tty device.

If there's an error, it gets printed and then ZLE resets the tty modes
and redraws the prompt; it's the tty mode setting in that case that causes
the access time to change.

This on a RedHat Linux system; it could be different on another OS.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-08-24 17:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-21  5:58 TRAPNAL with TMOUT problem Paul Lew
2000-08-21 17:48 ` Bart Schaefer
     [not found]   ` <14754.42242.721509.918727@paullew-ultra.cisco.com>
2000-08-22 18:24     ` Bart Schaefer
     [not found]       ` <14757.19686.238318.996093@paullew-ultra.cisco.com>
2000-08-24 17:27         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).