On Mon, Aug 20, 2012 at 10:15 PM, Roland Mainz <roland.ma...@nrubsig.org> wrote:
> Attached (as "astksh_builtin_poll20120819_001.diff.txt") is the 5th
> iteration of the poll(1) patch per review feedback...
>
> * Changes:
> - The test suite has been extended to cover fifos, POLLNVAL, POLLHUP,
> fd==-1 (to get entries ignored) and other little details.
>
> - Minor code cleanup and movements to make the |b_poll()| function
> smaller and more readable
>
>
> * Known issues:
> - Currently poll(1) doesn't work well with user-defined types (e.g.
> typeset -T ...). The problem is outlined in
> http://marc.info/?l=ast-developers&m=134526131905059&w=3 - it seems a
> compound variable within a type can't be extended with new elements in
> certain cases (e.g. in such cases the shell will abort the builtin
> instead of returning a plain "variable not found" (= return |NULL|
> pointer) to the calling C function).
> The "workaround" for using poll(1) with types is to declare _all_
> possible members in the "events" and "revents" variables, e.g. ...
> -- snip --
> typeset -T poll_t=( typeset -l -i fd ;
>     compound events=(  typeset pollin=false pollpri=false
> pollout=false pollrdnorm=false pollwrnorm=false pollrdband=false
> pollwrband=false pollmsg=false pollremove=false pollrdhup=false
> pollerr=false pollhup=false pollnval=false ; )
>     compound revents=( typeset pollin=false pollpri=false
> pollout=false pollrdnorm=false pollwrnorm=false pollrdband=false
> pollwrband=false pollmsg=false pollremove=false pollrdhup=false
> pollerr=false pollhup=false pollnval=false ; )
>     function pinit { _.fd=$1 ; _.events.pollin=true ; } ;
> )
> -- snip --
>
>
> * Future directions:
> - Implement support for plain string arrays (e.g. typeset -a/-A) for
> compatibility with a possible bash4 version of the poll(1) builtin
> (bash4 doesn't have compound variables... the idea is basically that
> if the array is made out of compound -a/-A or foo_t -a/-A the current
> mode is used... while if the array is a plain typeset -a/-A array it
> wil use plain strings for input/output (e.g. all information is
> squeezed into one single string)).
> The main idea is to get common functionality between bash4 and ksh93
> and then move forward and propose this to the Austin Group for the
> next POSIX standard.
>
> - It would be nice to have a way to open files via "redirect" (e.g. "
> command exec") with |O_NONBLOCK|. It seems to be part of POSIX (see
> http://pubs.opengroup.org/onlinepubs/7908799/xsh/open.html) and would
> help a lot if a process wants to open a fifo with seperate fds for
> both reading and writing. Right now we use the following trick to
> archive this...
> -- snip --
> mkfifo "${fifo_name}"
>
> # little "trick" with fifos - "redirect" would block if
> # there is no reader... so we create one in a
> # sub-process and kill it below after we opened the fd
> { redirect {dummy}<"${fifo_name}" ; for (( ;; )) ; do sleep 15 ; done ; } &
> (( pid=$! ))
>
> redirect {out_fd}>"${fifo_name}"
>
> kill $pid ; wait $pid 2>'/dev/null'
>
> redirect {in_fd}<"${fifo_name}"
> -- snip --
> ... but I'm not happy with this.
> IMO something like $ redirect --noblock {in_fd}<"${fifo_name} ;
> redirect {out_fd}>"${fifo_name}"" # would be nice... assuming all
> platforms supported by AST have |O_NONBLOCK| and support this for all
> of { fifos, pipes, sockets } as required by POSIX. Glenn ?

Erm... I forgot to say that the patch is for ksh93v- only. For ksh93u+
the old patch in
http://marc.info/?l=ast-developers&m=134431288721969&w=3 will just
work fine...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.ma...@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 3992797
 (;O/ \/ \O;)
_______________________________________________
ast-developers mailing list
ast-developers@research.att.com
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to