eufon

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5e423fb8fdfd8b4c5e37685c5e966e3f4af2e9d8
parent 11f4b123bf2c5da2ccfb76f6f212345f761f0db2
Author: Daniel Barlow <dan@telent.net>
Date:   Sun, 16 Jan 2022 17:04:47 +0000

saturn: change spawn behaviour

use fork() and exec() and close filehandles in child

Diffstat:
Msaturn/main.fnl | 17+++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/saturn/main.fnl b/saturn/main.fnl @@ -49,19 +49,20 @@ (fn spawn-async [vec] (let [pid (posix.unistd.fork)] - (if (> pid 0) - true - (< pid 0) - (assert (= "can't spawn" nil)) - (posix.spawn vec)))) + (if (> pid 0) true + (< pid 0) (assert (= "can't fork" nil)) + (do + (for [f 3 255] (posix.unistd.close f)) + (posix.execp "/usr/bin/env" vec))))) (fn launch [app] ; (print (if app.DBusActivatable "dbus" "not dbus")) (let [cmd (parse-percents app.Exec)] (if app.Terminal - (spawn-async ["/usr/bin/env" "kitty" cmd]) - (spawn-async ["/usr/bin/env" "sh" "-c" cmd])) - (os.exit))) + (spawn-async ["kitty" cmd]) + (spawn-async ["sh" "-c" cmd])) + (Gtk.main_quit) + (os.exit 0))) (fn button-for [app] (doto (Gtk.Button