[haiku-bugs] Re: [Haiku] #10941: [Terminal] closes when clicking hyperlink

  • From: "bonefish" <trac@xxxxxxxxxxxx>
  • Date: Sat, 14 Jun 2014 13:49:36 -0000

#10941: [Terminal] closes when clicking hyperlink
-------------------------------------+----------------------------
   Reporter:  diver                  |      Owner:  bonefish
       Type:  bug                    |     Status:  new
   Priority:  normal                 |  Milestone:  R1
  Component:  Applications/Terminal  |    Version:  R1/Development
 Resolution:                         |   Keywords:
 Blocked By:                         |   Blocking:
Has a Patch:  0                      |   Platform:  All
-------------------------------------+----------------------------

Comment (by bonefish):

 I've tracked the issue down to [http://cgit.haiku-
 
os.org/haiku/tree/src/apps/terminal/TermParse.cpp?id=bdd9f04c00a70dd8637c871689afe0b12821fac1#n255
 `TermParse::PtyReader()`] where a `TermBuffer::NotifyQuit()` is invoked
 when reading from the TTY failed. In this case it fails with
 `B_INTERRUPTED` due to a SIGCHLD being handled. The hyperlink is opened
 via `system("/bin/open ...")` and after having launched/notified whatever
 program is responsible for the link "open" quits and Terminal receives a
 SIGCHLD. If the signal is handled in the PTY reader thread while it is in
 the aforementioned `read()` in `TermParse::PtyReader()` the error occurs.

 In theory the same can happen when a shell is terminated with `exit` --
 i.e. the PTY reader from a different tab may handle the SIGCHLD and thus
 the wrong tab (in addition to the right one) may be closed. I don't think
 I have ever observed this; it may be unlikely due to how the timings of
 the different threads work out in this situation.

 Possible solutions:
  1. Handle the B_INTERRUPTED in `TermParse::PtyReader()` explicitly.
  2. Use a dedicated thread to handle SIGCHLD and block the signal in all
 other threads.

 Since the same or similar problems may occur in other parts of the code,
 1. may fix only one of the symptoms. 2. Requires a new thread, but would
 solve all similar issues for good. Using `sigwaitinfo()` it would be
 fairly simple to implement and we could even get rid of the signal handler
 and the extra thread that is spawned when the signal arrives.

--
Ticket URL: <https://dev.haiku-os.org/ticket/10941#comment:1>
Haiku <https://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: