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

Re: PATCH: zselect builtin.



"Bart Schaefer" wrote:
> On May 7, 12:25pm, Peter Stephenson wrote:
> } Subject: PATCH: zselect builtin.
> }
> } Here's a builtin to act as a front end to a `select' system call.  The
> } name clash with the `select' builtin is unfortunate but seems inevitable
> 
> Call it "selectfd" perhaps ... or "sys_select" the way perl does it.

Well, the convention with other bits and pieces is just to stick a `z'
in front to keep the namespace reasonably unpolluted.  Maybe zselectfd
would be OK?

> } Any comments before I commit this?
> 
> How about a -A (or -H, following `stat') option to store into an assoc?
> It might be nice if the keys returned were the FDs and the values were
> strings like "rwx" for the state of each descriptor, but if the keys were
> "-r", "-w" etc. with strings of space-separated FD numbers as values you
> could use `select ${(kv)=replyhash}', so I'm undecided.

The former might well be useful --- $reply[(i)$fd] doesn't easily tell you
about r, w, or x if you need to know that --- but it's pretty easy to
add later when I decide I can be bothered (or when anyone else can), so
at first I'll just commit it without.

> (I presume `select $reply' is the reason for the format you chose for the
> reply array.)

It wasn't so much that you'd ever want to use that as the simplicity of
having only one form for input and output.

By the way, I've fixed two things which I will put in the committed
version:  the array wasn't allocated to be long enough, so the null
char * was off the end, and there's no reason not to perform a `select'
when there are no fd's listed --- this gives you a higher resolution
sleep for free.  (I suppose I ought to reject it when there's no
timeout, either, but I don't know if that's too special a case to worry
about.  Maybe someone needs a blocking command.)

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



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