Opened 10 years ago

Closed 10 years ago

Last modified 10 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:
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 by bonefish, 10 years ago

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 by diver, 10 years ago

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

comment:3 by bonefish, 10 years ago

Status: newin-progress

in reply to:  2 comment:4 by bonefish, 10 years ago

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).

in reply to:  1 comment:5 by ttcoder, 10 years ago

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.