title: GTK - killing all subprocesses when application window is closed
body: <p>I noticed that if I kill the app launched from the command line, with CTRL+C - then the subprocesses get killed, while, when clicking the close button of the window title, the process remains running.</p>
  <pre class="lang-c prettyprint-override"><code>static void * spawn_process(void *data)
  {
      GError *local_error = NULL;
      GError **error = &amp;local_error;
      GSubprocess *process = g_subprocess_new (
          G_SUBPROCESS_FLAGS_INHERIT_FDS,
          error,
          &quot;podman&quot;,
          &quot;system&quot;,
          &quot;service&quot;,
          &quot;--time=0&quot;,
          &quot;unix:///tmp/podman.sock&quot;,
          &quot;--log-level=debug&quot;,
          NULL
      );
      g_assert_no_error (local_error);
      g_subprocess_wait_check(process, NULL, error);
      g_assert_no_error (local_error);
      g_object_unref (process);
      return NULL;
  }
  
  static void activate(GtkApplication *app) {
      GtkWidget *window = gtk_application_window_new(app);
      GThread *process_thread = g_thread_new(&quot;Podman service&quot;, &amp;spawn_process, NULL);
  }
  
  int main(int argc, char **argv) {
      GtkApplication *app = gtk_application_new(&quot;com.github.application.name&quot;,G_APPLICATION_FLAGS_NONE);
      g_signal_connect(app, &quot;activate&quot;, G_CALLBACK (activate), NULL);
      int status = g_application_run(G_APPLICATION (app), argc, argv);
      g_object_unref(app);
      return status;
  }
  </code></pre>