zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Cc: "lilydjwg@gmail.com" <lilydjwg@gmail.com>
Subject: Re: It seems that I find a zle -F full CPU bug
Date: Thu, 20 Feb 2014 12:47:18 -0800	[thread overview]
Message-ID: <CAH+w=7boWTG=CFF0L66qxBvC7Bs+Neg8pUazUp7TFPiVXfgAKA@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7ZQ3ivj3DOe0e4z7_w=Av-FvLxfxzdb3vtWQpzvhCmoLw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]

On Thursday, February 20, 2014, Bart Schaefer <schaefer@brasslantern.com>
wrote:

>
> Hmm ... looking at the loop, there is already some provision for this.  If
> poll() [or select()] returns -1, we discard all the handler FDs etc. and
> repeat with just the SHTTY FD.  I wonder if the situation that code is
> meant to handle is even possible.
>

Interrupt on a signal is a case where this can happen, it appears.


> Aside:  Am I misreading the code, or is it the case that the (HAVE_TIO &&
> sun) #ifdef branch does not support zle -F ?
>

If there is user typeahead this branch is going to read it and return.  If
not then it falls through to one of poll() or select() on the other
descriptors.  So I this appears OK, though it may be delayed more than
other cases in calling the handlers.


> The handler can know that the fd is closed in case of 'poll': the
>> handler will get an argument like 'hup' or 'nval'.
>
>
> I don't think the handler ever gets anything but a file descriptor number?


 Hmm.  It appears that a widget handlers (zle -F -w) will never get
anything but a descriptor number.  Without -w, the handler will get either
the descriptor number or a string describing the error condition (which
means in order to remove itself on an error, the handler has to know out of
band which descriptor it is watching?).  Those error-string values are not
documented.

However ... and again I may be reading this wrong ... I think the outer
test for whether to call the handler at all will skip the handlers for FDs
with error states.  In the HAVE_POLL branch, for example, it first looks
for the POLLIN flags but not for any error flags?  So it will never reach
the set of tests that examine POLLNVAL et al.?

That aside, dropping the invalid descriptors for the select() case is easy,
just change the bitflags.  For the poll() case it's going to be more work
because the fds[] array of structs will have to be rearranged.

  parent reply	other threads:[~2014-02-20 20:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140220050415.GA29027@lilyforest>
     [not found] ` <CAH+w=7Z+R_ZexSkesp2z+ndooHStOGJcMeWXtD7HCunjqJp9-Q@mail.gmail.com>
     [not found]   ` <20140220094053.137da74f@pwslap01u.europe.root.pri>
     [not found]     ` <20140220131659.GA21182@lilyforest>
2014-02-20 19:36       ` Bart Schaefer
2014-02-20 20:04         ` Peter Stephenson
2014-02-20 20:47         ` Bart Schaefer [this message]
2014-02-21 16:27           ` lilydjwg
2014-02-23 23:07           ` Bart Schaefer
2014-02-24 13:53             ` lilydjwg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7boWTG=CFF0L66qxBvC7Bs+Neg8pUazUp7TFPiVXfgAKA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=lilydjwg@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).