[seahorse/wip/nielsdg/fix-older-valac-errors] ssh: operation: Use Posix.Signal.TERM conditionally



commit e7b59749ee2512cb45ffa6e05fa890084ea145e2
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Apr 24 13:05:00 2019 +0200

    ssh: operation: Use Posix.Signal.TERM conditionally
    
    Starting from vala 0.40, `Posix.SIGTERM` was deprecated in favor of
    `Posix.Signal.TERM`. This was handled by
    https://gitlab.gnome.org/GNOME/seahorse/merge_requests/39, which
    unfortunately broke the code for older versions of Valac. Let's do a
    compromise and change the behaviour in and preprocessor macro `#if` that
    checks the valac version.

 ssh/operation.vala | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/ssh/operation.vala b/ssh/operation.vala
index 11e11c47..6efb7e17 100644
--- a/ssh/operation.vala
+++ b/ssh/operation.vala
@@ -80,8 +80,15 @@ public abstract class Operation : GLib.Object {
                                        on_spawn_setup_child, out this.pid, out fin, out fout, out ferr);
 
         ulong cancelled_sig = 0;
-        if (cancellable != null)
-            cancelled_sig = cancellable.connect(() =>  { Posix.kill(this.pid, Posix.Signal.TERM); });
+        if (cancellable != null) {
+            cancelled_sig = cancellable.connect(() =>  {
+#if VALA_0_40
+                Posix.kill(this.pid, Posix.Signal.TERM);
+#else
+                Posix.kill(this.pid, Posix.SIGTERM);
+#endif
+            });
+        }
 
         // Copy the input for later writing
         if (input != null) {
@@ -141,7 +148,11 @@ public abstract class Operation : GLib.Object {
             }
         } catch (GLib.Error e) {
             critical("Couldn't read output of SSH command. Error: %s", e.message);
+#if VALA_0_40
             Posix.kill(this.pid, Posix.Signal.TERM);
+#else
+            Posix.kill(this.pid, Posix.SIGTERM);
+#endif
             return false;
         }
 
@@ -159,7 +170,11 @@ public abstract class Operation : GLib.Object {
             }
         } catch (GLib.Error e) {
             critical("Couldn't write to STDIN of SSH command. Error: %s", e.message);
+#if VALA_0_40
             Posix.kill(this.pid, Posix.Signal.TERM);
+#else
+            Posix.kill(this.pid, Posix.SIGTERM);
+#endif
             return false;
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]