[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: [doc] read -t and sockets, devices...
From:       Stephane Chazelas <Stephane_Chazelas () yahoo ! fr>
Date:       2008-06-15 9:38:23
Message-ID: 20080615093823.GS5113 () sc ! homeunix ! net
[Download RAW message or body]

On Sat, Jun 14, 2008 at 10:15:06PM -0400, Chet Ramey wrote:
> Stephane Chazelas wrote:
>
>> What about a different $? (like 2 for timeout)?
>
> That's reasonable.  I'm thinking 128+SIGALRM.
[...]

That makes sense, but it's a bit of a pain to handle.

read -t 10 var; ret=$?
case $ret in
  (0) OK;;
  (1) EOF;;
  (*) if [ "$ret" -gt 128 ] && [ "$(kill -l "$ret")" = ALRM ]
      then TIMEOUT
      else UNKNOWN
      fi
      ;;
esac

-- 
Stéphane



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic