After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760874 - build panel cancel button does not cause autotools to abort build
build panel cancel button does not cause autotools to abort build
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: plugins
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-01-20 04:36 UTC by Christian Hergert
Modified: 2016-02-16 02:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Experimental changes to prove that the GCancellable is being triggered. (2.12 KB, patch)
2016-02-10 13:03 UTC, Debarshi Dutta
needs-work Details | Review
test case of make not getting killed (461 bytes, text/x-csrc)
2016-02-16 01:21 UTC, Christian Hergert
  Details
libide: use setsid() and kill(-pid, SIGKILL) to kill process group (3.66 KB, patch)
2016-02-16 02:24 UTC, Christian Hergert
committed Details | Review

Description Christian Hergert 2016-01-20 04:36:04 UTC
Something is awry with the GCancellable that gets cancelled between the cancel button being clicked and the cancellable used to perform a build operation.

This will need some tracking down to see if the cancellable is indeed getting triggered, and then how far down it goes. Ensure that the GSubprocess' that are spawned are using the same GCancellable.
Comment 1 Debarshi Dutta 2016-02-10 13:03:26 UTC
Created attachment 320796 [details] [review]
Experimental changes to prove that the GCancellable is being triggered.

This patch is just an experiment.

I have made the following changes and I believe that the same GCancellable is being used correctly. Also, I think that somehow the function to kill the GSubprocess isn't working. I have created and attached a handler function to the GCancellable, which when triggered, is calling g_subprocess_force_exit(process). However. This doesn't seem to work.The subprocess continues to build the files. (I call Cancel immediately after I call Build). Is there any other way I can terminate a subprocess().? Also in the APIs it says "Cancelling doesn't kill the subprocess. Call g_subprocess_force_exit() if it is desirable.". I have even tried using the g_subprocess_send_signal(process,9). Still it doesn't work.
Comment 2 Debarshi Dutta 2016-02-10 13:06:09 UTC
Also, here is my output when I press Build followed by Cancel immediately.

18:33:32.0003                          (null)[7367]:  WARNING: Spawned process in make all.

18:33:33.0130                          (null)[7337]:  WARNING: Invocation of force_exit process made here..

18:33:33.0130                          (null)[7367]:  WARNING: cancellable was triggered inside the subprocess

18:33:33.0131                          (null)[7337]:  WARNING: Operation was cancelled
Comment 3 Christian Hergert 2016-02-12 02:00:38 UTC
Excellent research. So perhaps we need to make a helper to handle the cancelled event and call force quit?

Interestingly, I'm working on IdeSubprocessLauncher on the wip/chergert/runtimes branch where we might be able to plumb this in. (We need the ability for runtimes to prefix shell commands with something like "xdg-app build ", so we are doing our own GSubprocessLauncher-like abstraction).
Comment 4 Christian Hergert 2016-02-16 01:21:02 UTC
Created attachment 321338 [details]
test case of make not getting killed

So here is a small test case that runs make and then kills the subprocess. You'll notice the subprocess doesn't die, and I think this is because the death signal isn't being inherited by the grandchildren.

We might need to create a process group leader, or some other mechanism (cgroup) to allow us to kill everything in the group.

Doing this in a portable fashion (I really only care about Linux, and BSD but to a lesser degree) is sort of painful, but seems possible.
Comment 5 Christian Hergert 2016-02-16 02:24:12 UTC
Created attachment 321339 [details] [review]
libide: use setsid() and kill(-pid, SIGKILL) to kill process group

We had an issue where "gmake", despite getting SIGKILL, would not cause
the build process to exit. This seems to be caused by the descendent
processes not dying with the parent.

To allow us to kill all of the processes, we first create a new session
group with setsid() in our child setup function. If the process should
be cancelled (via g_cancellable_cancel()), then we send SIGKILL to all
members of the session group with kill(-pid, SIGKILL). Specifying a
negated(pid) indicates delivery to all members of the group.

We probably need to verify that this works on FreeBSD, but it seems
plausible that will.
Comment 6 Christian Hergert 2016-02-16 02:27:05 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.