Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#10941 closed bug (fixed)

[Terminal] closes when clicking hyperlink

Reported by: diver Owned by: bonefish
Priority: normal Milestone: R1
Component: Applications/Terminal Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

hrev47371.

Terminal tab/window closes when clicking hyperlink. To repro:

  • Execute pwd
  • Hold command key and start clicking /boot/home hyperlink

Usually 5-10 times is enough to close current tab, though sometimes clicking it once is enough too.

Change History (5)

comment:1 Changed 5 years ago by bonefish

I've tracked the issue down to `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.

comment:2 Changed 5 years ago by diver

I should note that sometimes clicking a hyperlink also closes other Terminal tabs/windows.

comment:3 Changed 5 years ago by bonefish

Status: newin-progress

comment:4 in reply to:  2 Changed 5 years ago by bonefish

Resolution: fixed
Status: in-progressclosed

Replying to diver:

I should note that sometimes clicking a hyperlink also closes other Terminal tabs/windows.

That other windows are closed sounds somewhat dubious, since those belong to different processes and shouldn't get any signals related to the current one.

Fixed in hrev47384 as suggested in comment:1 (option 2).

comment:5 in reply to:  1 Changed 5 years ago by ttcoder

Replying to bonefish:

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.

I see that quite a bit, maybe once a day at least, when doing Alt-T/Alt-W in terminal even (and also with exit indeed), it sometimes closes the whole terminal. Doing my daily "pkgman update" right now to get the latest and greatest.. And thought I would mention to you the benefits these tickets fixes have on this guy here, among many others :-) Kudos.

Note: See TracTickets for help on using tickets.