Linux。哪个dll包含execv?
Linux. Which dll contains execv?
我需要在单声道应用程序中通过 PInvoke 调用此过程。
请只是图书馆的名字。
作为 GNU C 库的一部分,它位于 libc
:
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" }));
}
}
}
我需要在单声道应用程序中通过 PInvoke 调用此过程。 请只是图书馆的名字。
作为 GNU C 库的一部分,它位于 libc
:
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" }));
}
}
}