Loading ...
Sorry, an error occurred while loading the content.

Re: No break checks during shell operations in GUI mode?

Expand Messages
  • Bram Moolenaar
    ... This looks wrong. fast_breakcheck() reads input to see if a CTRL-C was typed. But the loop above has ui_inchar() that does this already. It sends a
    Message 1 of 16 , Feb 4 11:53 AM
    • 0 Attachment
      Bjorn Winckler wrote:

      > >> I've looked in todo.txt and not found this patch mentioned. Bram: did
      > >> you perhaps miss this patch?
      > >
      > > Eh, what patch?
      >
      > It was attached to the post I replied to in the original thread (I did
      > not include it inline since last time I did so the text got mangled).
      > Here it is again.

      This looks wrong. fast_breakcheck() reads input to see if a CTRL-C was
      typed. But the loop above has ui_inchar() that does this already. It
      sends a SIGINT to the child process group then.

      So what's the problem you are trying to solve?

      --
      The future isn't what it used to be.

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • björn
      ... The original problem was this: go to e.g. the vim src/ directory and enter :grep a *.c . During this operation it is impossible to halt Vim using
      Message 2 of 16 , Feb 4 12:12 PM
      • 0 Attachment
        2009/2/4 Bram Moolenaar:
        >
        > Bjorn Winckler wrote:
        >>
        >> It was attached to the post I replied to in the original thread (I did
        >> not include it inline since last time I did so the text got mangled).
        >> Here it is again.
        >
        > This looks wrong. fast_breakcheck() reads input to see if a CTRL-C was
        > typed. But the loop above has ui_inchar() that does this already. It
        > sends a SIGINT to the child process group then.
        >
        > So what's the problem you are trying to solve?

        The original problem was this: go to e.g. the vim src/ directory and
        enter ":grep a *.c". During this operation it is impossible to halt
        Vim using ctrl-c. (I've tested on Mac OS X, and sc confirmed the
        problem on Linux).

        When using a gui it seems ctrl-c is never handled but it does work
        without the gui so I figured that particular loop (where I added the
        breakcheck) only checked for SIGINT (since it is sent in console mode
        when ctrl-c is pressed, but not in the GUI). Adding the breakcheck
        fixed the problem so I guessed that this loop had only been tested
        properly without a gui.

        I had a look at ui_inchar() but I can't see where it handles ctrl-c
        when the gui is in use?

        Björn

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Andreas Bernauer
        ... I can t confirm this behavior for vim 7.2.095 on Linux 2.6.24 (in either gui or console mode). :grep interrupts as soon as I press Ctrl-C. -- Andreas.
        Message 3 of 16 , Feb 4 11:43 PM
        • 0 Attachment
          björn wrote:
          > 2009/2/4 Bram Moolenaar:
          >> So what's the problem you are trying to solve?
          >
          > The original problem was this: go to e.g. the vim src/ directory and
          > enter ":grep a *.c". During this operation it is impossible to halt
          > Vim using ctrl-c. (I've tested on Mac OS X, and sc confirmed the
          > problem on Linux).

          I can't confirm this behavior for vim 7.2.095 on Linux 2.6.24 (in either gui or
          console mode). :grep interrupts as soon as I press Ctrl-C.

          --
          Andreas.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Dominique Pelle
          ... I can reproduce the problem with gvim on Linux x86 (GUI GTK2): pressing CTRL-C does not interrupt :grep a * in gvim. In terminal, CTRL-C interrupts
          Message 4 of 16 , Feb 5 12:20 AM
          • 0 Attachment
            2009/2/5 Andreas Bernauer <andreas@...>:
            >
            > björn wrote:
            >> 2009/2/4 Bram Moolenaar:
            >>> So what's the problem you are trying to solve?
            >>
            >> The original problem was this: go to e.g. the vim src/ directory and
            >> enter ":grep a *.c". During this operation it is impossible to halt
            >> Vim using ctrl-c. (I've tested on Mac OS X, and sc confirmed the
            >> problem on Linux).
            >
            > I can't confirm this behavior for vim 7.2.095 on Linux 2.6.24 (in either gui or
            > console mode). :grep interrupts as soon as I press Ctrl-C.

            I can reproduce the problem with gvim on Linux x86 (GUI GTK2):
            pressing CTRL-C does not interrupt ":grep a *" in gvim.

            In terminal, CTRL-C interrupts ":grep a *" immediately (good).

            I tried the proposed patch, but it does not fix it for me: CTRL-C
            still does not interrupt ":grep a *" in the GUI.

            -- Dominique

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • Bram Moolenaar
            ... OK, I see the problem on FreeBSD as well. ... I m not sure how it is supposed to work. A brief look shows that it may have been intended that: the loop in
            Message 5 of 16 , Feb 5 11:44 AM
            • 0 Attachment
              Bjorn Winckler wrote:

              > >> It was attached to the post I replied to in the original thread (I did
              > >> not include it inline since last time I did so the text got mangled).
              > >> Here it is again.
              > >
              > > This looks wrong. fast_breakcheck() reads input to see if a CTRL-C was
              > > typed. But the loop above has ui_inchar() that does this already. It
              > > sends a SIGINT to the child process group then.
              > >
              > > So what's the problem you are trying to solve?
              >
              > The original problem was this: go to e.g. the vim src/ directory and
              > enter ":grep a *.c". During this operation it is impossible to halt
              > Vim using ctrl-c. (I've tested on Mac OS X, and sc confirmed the
              > problem on Linux).

              OK, I see the problem on FreeBSD as well.

              > When using a gui it seems ctrl-c is never handled but it does work
              > without the gui so I figured that particular loop (where I added the
              > breakcheck) only checked for SIGINT (since it is sent in console mode
              > when ctrl-c is pressed, but not in the GUI). Adding the breakcheck
              > fixed the problem so I guessed that this loop had only been tested
              > properly without a gui.
              >
              > I had a look at ui_inchar() but I can't see where it handles ctrl-c
              > when the gui is in use?

              I'm not sure how it is supposed to work. A brief look shows that it
              may have been intended that:
              the loop in os_unix.c calls ui_inchar()
              ui_inchar()
              -> read_from_input_buf()
              -> fill_input_buf()
              checks for CTRL-C and sets got_int

              So something in between stops this from happening.

              If I do ":!cat" then typing CTRL-C does appear to work. Perhaps it's
              the flood of output to the screen that stops the CTRL-C check? No time
              to investigate further right now.

              --
              hundred-and-one symptoms of being an internet addict:
              47. You are so familiar with the WWW that you find the search engines useless.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ download, build and distribute -- http://www.A-A-P.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_dev" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • björn
              ... Yes, this seems to be the problem. The difference between :!cat and :grep a *.c is that the former produces no output whereas the latter does and
              Message 6 of 16 , Feb 7 6:07 AM
              • 0 Attachment
                2009/2/5 Bram Moolenaar:
                >
                > If I do ":!cat" then typing CTRL-C does appear to work. Perhaps it's
                > the flood of output to the screen that stops the CTRL-C check? No time
                > to investigate further right now.

                Yes, this seems to be the problem. The difference between ":!cat" and
                ":grep a *.c" is that the former produces no output whereas the latter
                does and consequently Vim gets stuck in the loop on line 4368
                (os_unix.c) starting with

                while (RealWaitForChar(fromshell_fd, 10L, NULL))

                This loop is where I added the break check since there are no other
                checks for ctrl-c here. Only when this loop exits is ui_inchar()
                called and in the case of ":grep a *.c" this loop is iterated _many_
                times (up to 60000) before breaking out to call ui_inchar() again.

                Dominique: It is strange that my patch does not fix the problem for
                you...maybe fast_breakcheck() doesn't call gui_mch_update() often
                enough on your system (although that seems unlikely judging from the
                amount of times this loop iterates as I mentioned above)? It does
                take care of the problem on my machine (Mac OS X 10.5.6, Vim 7.2
                patches 1-102, with MacVim GUI).

                Anyway, I don't know what the proper way to fix this problem is then
                seeing as it's not working for Dominique. But somehow we have to
                ensure that this problematic loop doesn't get stuck for "too long"
                (whatever metric we may use to measure that) or that we check for
                ctrl-c explicitly during the loop (which was what my patch was
                supposed to do). Any ideas?

                Björn

                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_dev" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • Bram Moolenaar
                ... I think we need to break out of the loop now and then to check for a CTRL-C. Question is: when? There is some code in place to avoid calling ui_inchar(),
                Message 7 of 16 , Feb 7 7:56 AM
                • 0 Attachment
                  Bjorn Winckler wrote:

                  > 2009/2/5 Bram Moolenaar:
                  > >
                  > > If I do ":!cat" then typing CTRL-C does appear to work. Perhaps it's
                  > > the flood of output to the screen that stops the CTRL-C check? No time
                  > > to investigate further right now.
                  >
                  > Yes, this seems to be the problem. The difference between ":!cat" and
                  > ":grep a *.c" is that the former produces no output whereas the latter
                  > does and consequently Vim gets stuck in the loop on line 4368
                  > (os_unix.c) starting with
                  >
                  > while (RealWaitForChar(fromshell_fd, 10L, NULL))
                  >
                  > This loop is where I added the break check since there are no other
                  > checks for ctrl-c here. Only when this loop exits is ui_inchar()
                  > called and in the case of ":grep a *.c" this loop is iterated _many_
                  > times (up to 60000) before breaking out to call ui_inchar() again.
                  >
                  > Dominique: It is strange that my patch does not fix the problem for
                  > you...maybe fast_breakcheck() doesn't call gui_mch_update() often
                  > enough on your system (although that seems unlikely judging from the
                  > amount of times this loop iterates as I mentioned above)? It does
                  > take care of the problem on my machine (Mac OS X 10.5.6, Vim 7.2
                  > patches 1-102, with MacVim GUI).
                  >
                  > Anyway, I don't know what the proper way to fix this problem is then
                  > seeing as it's not working for Dominique. But somehow we have to
                  > ensure that this problematic loop doesn't get stuck for "too long"
                  > (whatever metric we may use to measure that) or that we check for
                  > ctrl-c explicitly during the loop (which was what my patch was
                  > supposed to do). Any ideas?

                  I think we need to break out of the loop now and then to check for a
                  CTRL-C. Question is: when? There is some code in place to avoid
                  calling ui_inchar(), because it eats typeahead.

                  Perhaps the "noread_cnt" variable can be extended with something that
                  keeps track of how long ago ui_inchar() was called. It should probably
                  be called every half a second to be responsive to CTRL-C.

                  --
                  hundred-and-one symptoms of being an internet addict:
                  58. You turn on your computer and turn off your wife.

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ download, build and distribute -- http://www.A-A-P.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_dev" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • Dominique Pelle
                  ... Ah, I now notice that the patch does not work when I use gvim in a ssh session ssh -Y (which is how I tested initially). But if I use gvim locally,
                  Message 8 of 16 , Feb 7 8:17 AM
                  • 0 Attachment
                    björn wrote:

                    > Dominique: It is strange that my patch does not fix the problem for
                    > you...maybe fast_breakcheck() doesn't call gui_mch_update() often
                    > enough on your system (although that seems unlikely judging from the
                    > amount of times this loop iterates as I mentioned above)?  It does
                    > take care of the problem on my machine (Mac OS X 10.5.6, Vim 7.2
                    > patches 1-102, with MacVim GUI).

                    Ah, I now notice that the patch does not work when I use gvim in
                    a ssh session 'ssh -Y' (which is how I tested initially). But if I
                    use gvim locally, then your patch works. Well, there is a bit of
                    lag: when pressing <ctrl-c> it stops grep after maybe 2 seconds
                    or so. Still better than not stopping it at all. In the terminal,
                    pressing <ctrl-c> stops grep immediately. I'm using gvim-7.2.102
                    with GTK2 GUI on Linux x86.

                    -- Dominique

                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_dev" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  Your message has been successfully submitted and would be delivered to recipients shortly.