]> nmode's Git Repositories - Fey/commitdiff
Add option to fork processes
authorNaeem Model <me@nmode.ca>
Tue, 13 May 2025 14:46:54 +0000 (14:46 +0000)
committerNaeem Model <me@nmode.ca>
Tue, 13 May 2025 14:46:54 +0000 (14:46 +0000)
lib/App/Fey.pm

index 9939a5c729fe1fb5e5cce3e02cf82e1ed8de4936..89f6535a3f28c7fa75482ae885eb2cc9017e8bc8 100644 (file)
@@ -30,6 +30,11 @@ sub launch {
     die "No files or URIs specified.\n" unless @_;
 
     ARG: for my $file_or_uri (@_) {
+        if ($options->{fork} && !$options->{single}) {
+            my $pid = fork;
+            next ARG if ($pid);
+        }
+
         if ($file_or_uri =~ m|^file://(.+)|) {
             $file_or_uri = $1;
         }
@@ -52,6 +57,7 @@ sub launch {
                                 return;
                             }
                             $associations->{$context}->($file_or_uri);
+                            return if ($options->{fork});
                             next ARG;
                         }
                     }