Giter Site home page Giter Site logo

Comments (18)

jeremypw avatar jeremypw commented on June 11, 2024 1

In most cases the user will "Force Quit" anyway so there seems little harm in doing it code?

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

So the issue is that the tab cannot be closed with the close button if the child is a zombie? Do you know why the child became zombified? Is there a way of detecting a zombie in code?

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

I actually don't know why it becomes a zombie :-(

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

If the cause is external to Terminal/Elementary, then throwing that dialog with a Force Quit option seems a reasonable response pro temp pending an upstream fix. Otherwise we need to stop the zombification.

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

😞 Yeah I am still looking into it, it seems that it only becomes a zombie when the first Posix.kill (this.child_pid, Posix.Signal.HUP); happened and it was not zombie before. Actually this is what I did:

public void term_ps () {
    killed = true;

    warning (this.child_pid.to_string ());
    Thread.usleep (10000000);
    Posix.kill (this.child_pid, Posix.Signal.HUP);
    // Posix.kill (this.child_pid, Posix.Signal.TERM);
    warning ("Done");
    while (true) { }
}

Do you have any suggestions on how to debug this? I actually tried launching a random zenity process (outside of the elementary terminal), get the pid and replace this.child_pid with it like:

public void term_ps () {
    killed = true;

    // warning (this.child_pid.to_string ());
    Thread.usleep (10000000);
    Posix.kill (145200, Posix.Signal.HUP);
    // Posix.kill (this.child_pid, Posix.Signal.TERM);
    warning ("Done");
    while (true) { }
}

While the terminal still freeze (as expected) Posix.kill actually successfully hang up the zenity process.

Update: Also tried using a pid from a zsh which is launched in a xterm terminal, with the same steps Posix.kill is still able to hang up the external zsh.

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

I'll have a look into it and see if I can reproduce. Perhaps we should not be able to close a tab with running child anyway? What becomes of a the child process if Terminal is terminated some other way?

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

What setting save-exited-tabs do you have? If this is true then the shell process for closed tabs will continue until the Terminal window is closed and when that tab is restored no new shell process is created. The default setting on Elementary is true.

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

I have switch my default shell to zsh but as yet not reproduced the freeze.

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

Can you reproduce this on NixOS using bash as the shell?

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

Can you reproduce this on NixOS using bash as the shell?

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

gsettings get io.elementary.terminal.settings save-exited-tabs gave me true. Yeah it can be possible that those GNOME 43 packages are needed to reproduce the issue :-(

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

Can you reproduce this on NixOS using bash as the shell?

Yes (actually my laptop is using zsh but the screenshot above is a VM that uses bash)

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

Unfortunately the commit that introduced this possibility of an infinite loop by removing the maximum number of tries to kill the shell process is too old for me to find out what issue this was supposed to fix. It would seem sensible to impose a maximum number of retries.

from terminal.

jeremypw avatar jeremypw commented on June 11, 2024

Just tried commenting out the while of that loop so Terminal no longer tries to close the shell process. The processes and any child processes get closed anyway so 🤷

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

Can https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2408 be the reason of this issue? I actually did some bisect and noticed that MR.

/cc @jtojnar

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

Hmmm... So maybe this will be another possible workaround?

public void term_ps () {
    killed = true;

    Posix.kill (this.child_pid, Posix.Signal.HUP);
    Posix.kill (this.child_pid, Posix.Signal.TERM);

    int status;
    Posix.waitpid (this.child_pid, out status, 0);
}

From my testing the terminal will no longer freeze when closing but you will get a new warning (when closing the terminal) if you build it with GLib 2.72.3

[GLib] GChildWatchSource: Exit status of a child process was requested but ECHILD was received by waitpid(). See the documentation of g_child_watch_source_new() for possible causes.

The warning does not present if you build with GLib 2.74.0 however.

from terminal.

bobby285271 avatar bobby285271 commented on June 11, 2024

Okay, sounds like waitpid is the correct way, let's just do this conditionally: cockpit-project/cockpit#17564 Ah no, see the PR below, which uses pidfd

from terminal.

T-O-R-U-S avatar T-O-R-U-S commented on June 11, 2024

I'm also experiencing this freeze when trying to close the terminal -- though I'm not running the official distro of Elementary, I'm running Pantheon on my Arch install.

from terminal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.