Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Alternative time out

_timexit ()
{
# ( --- ) Combine commands in the function to not get their pid:
    ( while true;
    do
# Find the pid of the previous command in real time,
# If the pid does not exist the loop is broken:
        grep -q -o $! <<<$(ps ax) || break 2> /dev/null
# Counts according to the value given in the argument:
        te=$[$te+1]
# Kill the process if it exceeds the time:
        [ $te == ${@} ] && {
            kill -s PIPE $! 2> /dev/null
            break 2> /dev/null
        }
        sleep 1;
    done )
}
# /Example use:
( w3m -o accept_encoding=UTF-8 -dump_source https://rextester.com | grep bash & >/dev/null ) &
_timexit 10
 run  | edit  | history  | help 1