monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] spawn pipe patch


From: William Uther
Subject: [Monotone-devel] spawn pipe patch
Date: Mon, 20 Nov 2006 23:44:54 +1100

Hi all,

Here is another patch. It adds the ability to spawn a new process, like popen, but not parsed by the shell, so it is safe.

Caveats:

  I've only implemented the Unix side of this, not the Win32 side.
  There are no unit tests as yet.
  It would be good if someone could review the lua integration.


Attachment: spawn_pipe.patch
Description: Binary data


I've tested it with a monotonerc:

function get_passphrase(keypair_id)
        procfin, procfout, pid = spawn_pipe("testSh")
        print("pid: " .. pid)
        procfin:write("lua text")
        procfin:close()
        print("closed procfin")
        line, errstr = procfout:read()
        while line ~= nil do
                print("read: " .. line)
                if errstr ~= nil then
                        print("errstr: " .. errstr)
                end
                line, errstr = procfout:read()
        end
        if errstr ~= nil then
                print("errstr: " .. errstr)
        end
        procfout:close()
        print("closed procfout")
        ret, pid = wait(pid)
        print("child done")
        return ""
end

where testSh is:

#! /bin/sh
echo "Stdout"
echo "Stderr" 1>&2
cat

Be well,

Will        :-}


reply via email to

[Prev in Thread] Current Thread [Next in Thread]