The following commit has been merged in the sourcev3 branch:
commit 1af699c6e4ed32317926452b582e84a20ff2f521
Author: Frank Lichtenheld <[EMAIL PROTECTED]>
Date:   Fri Feb 15 21:30:15 2008 +0100

    Dpkg::IPC: New {to,from}_string options for fork_and_exec
    
    * scripts/Dpkg/IPC.pm (fork_and_exec): Add new options
    {to,from}_string. For symmetry reasons both options take
    a scalar reference, even though this is really only
    necessary for to_string. to_string implies the
    wait_child option.

diff --git a/scripts/Dpkg/IPC.pm b/scripts/Dpkg/IPC.pm
index 7f8a46a..eb42854 100644
--- a/scripts/Dpkg/IPC.pm
+++ b/scripts/Dpkg/IPC.pm
@@ -1,4 +1,5 @@
 # Copyright 2008 Raphaël Hertzog <[EMAIL PROTECTED]>
+# Copyright 2008 Frank Lichtenheld <[EMAIL PROTECTED]>
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -38,6 +39,14 @@ sub fork_and_exec {
     } else {
        error(_g("invalid exec parameter in fork_and_exec()"));
     }
+    my ($from_string_pipe, $to_string_pipe);
+    if ($opts{"to_string"}) {
+       $opts{"to_pipe"} = \$to_string_pipe;
+       $opts{"wait_child"} = 1;
+    }
+    if ($opts{"from_string"}) {
+       $opts{"from_pipe"} = \$from_string_pipe;
+    }
     # Create pipes if needed
     my ($input_pipe, $output_pipe);
     if ($opts{"from_pipe"}) {
@@ -81,6 +90,14 @@ sub fork_and_exec {
     close($opts{"from_handle"}) if exists $opts{"from_handle"};
     close($opts{"to_handle"}) if exists $opts{"to_handle"};
 
+    if ($opts{"from_string"}) {
+       print $from_string_pipe ${$opts{"from_string"}};
+       close($from_string_pipe);
+    }
+    if ($opts{"to_string"}) {
+       local $/ = undef;
+       ${$opts{"to_string"}} = readline($to_string_pipe);
+    }
     if ($opts{"wait_child"}) {
        wait_child($pid, cmdline => "@prog");
        return 1;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to