Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: TRAPNAL with TMOUT problem



On Aug 22,  9:06am, Paul Lew wrote:
} Subject: Re: TRAPNAL with TMOUT problem
}
} >>>>> "Bart" == Bart Schaefer <schaefer@xxxxxxxxxxxxxxxxxxxxxxx> 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   



Messages sorted by: Reverse Date, Date, Thread, Author