Linux操作系统。哪个dll包含execv?

时间:2015-10-20 11:31:45

标签: linux mono pinvoke

我需要在单声道应用程序中通过PInvoke调用此过程。 请来图书馆的名字。

1 个答案:

答案 0 :(得分:2)

作为GNU C lib的一部分,它位于libc

  

http://linux.die.net/man/3/execv

using System;
using System.Runtime.InteropServices;

namespace posix
{
    class MainClass
    {
        [DllImport ("libc", SetLastError=true)]
        private static extern int system (string exec);

        [DllImport ("libc", SetLastError=true)]
        public static extern int execv (string path, string[] argv);

        public static void Main (string[] args)
        {
            Console.WriteLine ("Error:{0}", system ("ls -l"));
            Console.WriteLine ("Error:{0}", execv ("/usr/bin/vi", new string[] { "/usr/bin/vi" , "foobar.txt" }));
            // Of course, being execv without failure we never come back...
            Console.WriteLine ("Should never be displayed");
            Console.WriteLine ("Error:{0}", Mono.Unix.Native.Syscall.execv ("/usr/bin/ls", new string[] { "/usr/bin/ls" }));
        }
    }
}