commit: 14cd0fec836cf228b2279da0c53ae43a32d7b1fb
parent: 588f15f4e7454f8bba04e9617e4808a07605c028
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 7 Jan 2019 05:54:37 +0100
badwolf.c: Handle web-process-terminated
Diffstat:
1 file changed, 23 insertions(+), 0 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -11,6 +11,28 @@ static gboolean WebViewCb_close(WebKitWebView *_webView, GtkWidget *window)
return TRUE;
}
+static gboolean WebViewCb_web_process_terminated(WebKitWebView *web_view, WebKitWebProcessTerminationReason reason, gpointer user_data)
+{
+ char *str_reason;
+
+ switch(reason) {
+ case WEBKIT_WEB_PROCESS_CRASHED:
+ str_reason = "the web process crashed.";
+ break;
+ ;;
+ case WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT:
+ str_reason = "the web process exceeded the memory limit.";
+ break;
+ ;;
+ default:
+ str_reason = "the web process terminated for an unknown reason.";
+ ;;
+ }
+
+ fprintf(stderr, "BadWolf [signal: web-process-terminated]: %s", str_reason);
+ return TRUE;
+}
+
static gboolean WebViewCb_notify__uri(WebKitWebView *webView, GtkWidget *location)
{
const gchar *location_uri;
@@ -45,6 +67,7 @@ int main(int argc, char *argv[])
g_signal_connect(main_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(webView, "close", G_CALLBACK(WebViewCb_close), main_window);
+ g_signal_connect(webView, "web-process-terminated", G_CALLBACK(WebViewCb_web_process_terminated), NULL);
g_signal_connect(webView, "notify::uri", G_CALLBACK(WebViewCb_notify__uri), location);
WebKitSettings *settings = webkit_web_view_get_settings(webView);