]> nmode's Git Repositories - Fey/blobdiff - lib/App/Fey.pm
Add option to fork processes
[Fey] / 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 (@_) {
     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;
         }
         if ($file_or_uri =~ m|^file://(.+)|) {
             $file_or_uri = $1;
         }
@@ -52,6 +57,7 @@ sub launch {
                                 return;
                             }
                             $associations->{$context}->($file_or_uri);
                                 return;
                             }
                             $associations->{$context}->($file_or_uri);
+                            return if ($options->{fork});
                             next ARG;
                         }
                     }
                             next ARG;
                         }
                     }